2

As a follow on from: How translate this curl command into a R curl call?

I can successful do a curl request but the returned result looks to be in a binary format, but the content should be ASCII. How do I write it out as an ASCII file?

require(httr)

headers = c(
  `Content-Type` = 'text/csv'
)

data = upload_file('data/data.csv')
res <- httr::POST(url = 'https://some.url.com/invocations', httr::add_headers(.headers=headers), body = data)
xiaodai
  • 14,889
  • 18
  • 76
  • 140

1 Answers1

1
content(res, "text")

works and if the output is JSON then

content(res, "parsed")

works too.

xiaodai
  • 14,889
  • 18
  • 76
  • 140