Reputation: 6674
An API I am using is telling me to make a GET request as follows:
curl -s \
-X GET \
--user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
https://api.mailjet.com/v3/REST/template/$template_ID/detailcontent
and I am trying to convert this to Rails' NET::HTTP
. I've tried adding a req.body
, adding ?user=TOKEN
and keep getting a 401 Unauthorized
response. I've tested it in curl and my credentials are valid.
How do I include the --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE"
portion in my GET request?
Upvotes: 0
Views: 70
Reputation: 2483
--user
in curl is used for server authentication. In your case, after --user
you provide username and password separated with colon. This will be used for the http basic authentication.
Since you know that, you can check how to do the basic authentication with NET::HTTP here or here.
Upvotes: 1