Search code examples
rgethttr

Access issue while using httr package in R


I have the following details of an app:

http://45.56.112.95/location/
Device-Id: fd2364ca08f871
client-info: XXXXX
client-version: 13605
Client-Key: XYZ
Device-Info: 5.0 (asus ASUS_Z00AD)
client: mobile_android
X-Api-Version: 2.0
Latitude: 28.6254984
Longitude: 77.3783081

I have tried two ways to access the app using httr package in R but have been unsuccessful. Below is the query and the error received:

**First Try**
a <- GET("http://45.56.112.95/location/", add_headers(.headers = c(Client-Key="XYZ", Latitude = "28.6254984", Longitude = "77.3783081" )))

Error: unexpected '=' in "a <- GET("http://45.56.112.95/location/", add_headers(.headers = c(Client-Key="

**Second Try**
a = GET("http://45.56.112.95/location/", authenticate("Client-Key", "XYZ"), add_headers(.headers = c(Latitude = "28.6254984", Longitude = "77.3783081")))

Client error: (403) Forbidden

I am not sure if my query is correct and this is actually an authorization issue. Or if my query is wrong. Thanks in advance.


Solution

  • try putting quotes around Client-Key?

    a <- GET("http://45.56.112.95/location/", add_headers(.headers = c("Client-Key"="XYZ", Latitude = "28.6254984", Longitude = "77.3783081" )))