Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

How can I get a 201 API response in R?

$
0
0

I'm trying to get post an API request at an adserver to later get a specific report with the GET function. But first I have use POST with a specific body to specify the report. It works with the talent API tester but I can't figure out how to translate it to R.

My POST function looks like this:

library(httr)

url <- "https://reporting.smartadserverapis.com/646/reports"
body <- '{"startDate":"2019-12-01T00:00:00",
 "endDate":"2020-01-01T00:00:00",
 "fields": [{"Day": {} },  { "AdvertiserName": {} }, { "InsertionName": {} }, { "Keyword": {"value":""} }, { "Clicks": {} }, { "ClickBots": {} }] }'

POST(url, body = jsonlite::toJSON(dat_json), authenticate("myuser", "mypassword"))

But no matter what I put in the body, or wether I use authenticate or not I always get the same response with the POST function:

POST(url = url, body = "test") Response [https://reporting.smartadserverapis.com/646/reports] Date: 2020-01-16 10:10 Status: 200 Content-Type: application/json; charset=utf-8 Size: 209 B

But I'm actually expecting a 201 response with a taskId and an instanceId.

Thanks in advance!

Cheers


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>