Hi guys !
I need to run a one-time HTTP query in one of my projects, it needs to include a PEM certificate and since I was not able to find any documentation on how to do it with either hackney or mint, I decided to do it using System.cmd/2
.
The valid CURL command looks like this:
curl --request POST \
--url https://xxxx \
--cert ./certdir/cert.pem \
--key ./certdir/cert-key.pem \
--verbose -H "Content-Type: application/json" \
-d '{"merchantIdentifier": "xxx", "domainName":"xxx","displayName":"xxx"}'
This works as expected. However, I tried many things but was not able to run the same command from Elixir. I tried as a single string, I tried with ~s, ~w etc… and I always end up with unmatched close brace/bracket in URL position 2:
error.
This is what it looks like:
{res, _n} = System.cmd("curl", ~w[
https://xxx
--request POST
--cert ./certdir/cert.pem
--key ./certdir/cert-key.pem
-H 'Content-Type: application/json'
-d '{"merchantIdentifier": "xxx", "domainName":"xxx","displayName":"xxx"}
])
Any idea why it fails? I never got any issue with this and I am honestly confused about what’s happening and very frustrated to get stuck on such a small issue.
Thank you!