How I would write the following curl POST method using R and the RCurl package?
curl -k -u myusername:mypassword -d '{"text":"Hello World!","level":"Noob"}' -H "Content-Type: application/json" -H "Accept: application/json" "http://api.website/v1/access?"
FINAL EDIT: After emailing the great Duncan Temple Lang I have a solution:
My previous post is below but it has all now been superseded by the edit above (I’ve left the below for reference):
I would like to know the answer to this question myself. even looking at TARehman’s answer I still can’t work out how to do it (my lack of understanding is no doubt the root).
If you download curl from its website (I used the generic-win binary version), then here’s one way of doing it in R via the ‘system’ command which is like using the window’s command line window but from R:
The above works with one of the API’s I use. You can then use
I really hope you find an answer because it would be useful for me to know too.
EDIT: My attempt using an actual API with RCurl via @TARehman’s example:
Here is the curl code which works fine:
And here is how I’ve rewritten it in RCurl:
This however did not work and results in the following (clearly I have not understood something correctly):