Search code examples
rcurlrcurlhttr

Build an equivalent R request for a curl request


I have the following curl request:

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

How can I run the request in R?


Solution

  • 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.