0

I'm trying to pull some data from Zuora, but rjson is throwing an error.

library(httr) 
library(rjson)

query <- "https://api.zuora.com/rest/v1"
getdata <- GET(url=query, add_headers(apiAccessKeyId="Username", apiSecretAccessKey = "Password", Content-Type = "application/json"))
q <- fromJSON(content(getdata,type="text"))

The error:

No encoding supplied: defaulting to UTF-8.
Error in fromJSON(content(getdata, type = "text")) : 
  unexpected character '<'

Any help is greatly appreciated.

Joseph Noirre
  • 387
  • 4
  • 20

1 Answers1

0
auth <- add_headers(apiAccessKeyId = "username", apiSecretAccessKey = "password")
body = paste('{
  "Format": "csv",
             "Name": "test",
             "Query": "select * from invoice",
             "Status": "Processing",
             "Zip": false
             }')

getdata <- POST("https://rest.zuora.com/v1/object/export", auth, body = body)
r <- fromJSON(content(getdata, type = "text"))
Joseph Noirre
  • 387
  • 4
  • 20