curl -X GET https://www.dntly.com/api/v1/accounts.json \
-u dt_SAMPLETOKENd88ffc342dde5c195df4019f90d6ed:
I am able to do this in Terminal, but how can I request this with Httparty? Or how do I call json data that requires authentication through rails model?
Any best practices or resources you guys know will be greatly appreciated too!
I would probably not do that in the AR model, how do you feel about creating a class that knows how to pass the correct params for httpParty to build the request? I dont know what these are specifically to looking at the repo it shouldn’t be hard to find. As an additional step, I’d consider also creating a parser to handle the response.
I do realise that this isnt very helpful info, and I’ll have a read of the httpParty docs to help some more when I get the chance
In curl, the -u flag indicates http authentication, but the lack of anything after the colon indicates that the password is blank, which seems a little odd.
This example from the docs shows how to make an HTTP auth request. For your case, it should look something like:
I know this is off topic but my question is also curl related:
I would like to make a post request to Ionic’s push notifications api from inside a Rails App.
The sample code provided in in Python and I have trouble converting it to Ruby.
I would appreciate any help: