5

I have the following curl request:

curl --request GET --header "key: value" http://urlhere

How can I run the request in R?

rmuc8
  • 2,869
  • 7
  • 27
  • 36
tushaR
  • 3,083
  • 1
  • 20
  • 33

1 Answers1

7

You can use the GET function:

library(httr)
r <- GET("http://urlhere", add_headers(key = value))

add_headers allows you to add header data to your request.

If you use ?GET you can see more information and options.

mucio
  • 7,014
  • 1
  • 21
  • 33
  • Thanks for the quick help. I tried it but I am getting Status: 401 as response to the request. Could this be some permissions issue? – tushaR Apr 24 '15 at 08:41
  • 1
    Yep, 401 is unauthorized error code. More info on [List of HTTP status codes](http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_Client_Error) – mucio Apr 24 '15 at 09:49