I am using the R package httr to send a POST requests. I know how the body of the reqeust should look like, but I was not able to create it using httr. I am always missing a pair of square brackets (see below).
How do I have to modify my R code to get the desired result?
This is the R POST-snippet
cells <- c("Dimensions('Time')/Hierarchies('Time')/Elements('ABC')",
"Dimensions('Currency')/Hierarchies('Currency')/Elements('USD')")
value <- 123
with_verbose(
httr::POST(
url = url,
config = httr::config(ssl_verifypeer = FALSE, ssl_verifyhost = FALSE),
body = list(Cells = list(`Tuple@odata.bind` = cells), Value = value),
content_type("application/json"),
encode = "json",
set_cookies(...),
handle = handle
) %>% httr::content()
)
desired body to be sent:
{
"Cells":[
{"Tuple@odata.bind":[
"Dimensions('Time')/Hierarchies('Time')/Elements('ABC')",
"Dimensions('Currency')/Hierarchies('Currency')/Elements('USD')"
]}
],
"Value":"123"
}
actual body that is sent:
{
"Cells": ######### Missing bracket here #######
{"Tuple@odata.bind":[
"Dimensions('Time')/Hierarchies('Time')/Elements('ABC')",
"Dimensions('Currency')/Hierarchies('Currency')/Elements('USD')"
]},
####### Missing bracket here #######
"Value":"123"
}