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