How do I convert this command:
curl -X POST --user API_TOKEN:x https://app.bluefolder.com/api/2.0/serviceRequests/list.aspx
--data "<request><listType>full</listType></request>"
to
curl command in Rcurl?
I was given an API Token that replaces API_TOKEN in the code above. I'm trying to use Rcurl to retrieve data and export it to a csv file on my shared network drive. I tested the code above in Git Bash and it worked. When I try R, I run into errors. I will use Example123 as the token example.
# devtools::install_github("hrbrmstr/curlconverter")
library(curlconverter)
#Pasting curl command line
flat <- straighten("curl -X POST --user Example123:x https://app.bluefolder.com/api/2.0/serviceRequests/list.aspx
--data '<request><listType>full</listType></request>'")
#Turns the URL parts list into a fully functional httr call. It's vectorized.
req <- make_req(flat)[[1]]
req
#Reformat the function source to make it more readable
httr::VERB(verb = "POST",
url = "https://app.bluefolder.com/api/2.0/serviceRequests/list.aspx",
httr::authenticate(user = "Example123", password = "x"),
httr::verbose(),
httr::add_headers(),
encode = "json")
#Translate that to a plain POST call without namespacing
POST(url = "https://app.bluefolder.com/api/2.0/serviceRequests/list.aspx",
authenticate(user = "Example123", password = "x"),
verbose(),
add_headers(),
encode = "json")
The error I get:
<response status='fail'>
<error code='400'>
<![CDATA[Invalid request: request is empty.]]>
</error>