0

looking to pass $filter criteria using odata in R's httr package, but keep getting an 'Error 400. The request is badly formed'.

I'm able to paste the url/$filter in my browser and obtain results ok, and am also to obtain results in R without the $filter. It's just using the $filter option in R that I'm getting the error:

library(httr)
url <- "https://api.prosper.com/api/ListingsHistorical?$filter=year(ListingCreationDate) eq 2014"
response <- GET(url, authenticate('user', 'pass')

Above, in R, is what's throwing the 400 response. In browser works fine.

  • We would need a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – MrFlick Apr 28 '15 at 23:27
  • That URL works in-browser for you? Which browser? I get a 404 error message. – MrFlick Apr 28 '15 at 23:44
  • apologize, forgot to include a '?'. URL has been updated - I'm using Safari on OS X Yosemite (10.10.2) – user1546818 Apr 28 '15 at 23:54
  • 1
    Looks like that URL requires authentication. Did you make any attempt in the code to authenticate? – MrFlick Apr 28 '15 at 23:56
  • Yes, in the 3rd line I pass the authentication requirements (names changed to protect the innocent). It works fine without the $filter argument in R – user1546818 Apr 29 '15 at 00:06

1 Answers1

1

Figured it out. I needed to include %20 for the spaces when declaring the url variable.

Working:

library(httr)
url <- "https://api.prosper.com/api/ListingsHistorical?$filter=year(ListingCreationDate)%20eq%202014"
response <- GET(url, authenticate('user', 'pass')