0

I am trying to download data in R via an API using OData protocol. I am new to APIs so please bear with me.

I am trying to send a GET command using the following from the API specs:

https://address/v1/meter?$filter=GroupGUID eq guid’ID’

where address is replaced by the URL and ID is replaced by the ID of the meter. The API uses basic authorization, so I am using the following code from the httr library:

MyUrl <- "https://address/v1/meter?$filter=GroupGUID eq guid'ID'"
MyData <- GET(MyUrl, authenticate("Username", "access code", "basic")) 

This gives an status code 400 - The request is badly formed

The authentication works, when I am not using the $filter command. I have been in touch with the developers of the API and they have confirmed that my GET command is correct. But they are not familiar with R, so they cannot help. I suspect that it may be the space before and after “eq” that is causing the problem.
Can anyone help or point me to a description of using the Odata protocol in R? Best regards, Rune

Rune
  • 1
  • 1

1 Answers1

0

I finally figured it out. If I replace space " " with "%20", it works.

This solution is also described her: passing odata $filter in httr GET request

Rune
  • 1
  • 1