Hi All,
I would like to create a request to the API in R, but I am trying to find the correct inputs to httr2 https://httr.r-lib.org/reference/POST.html, even after reading its documentation. I am not sure of the placement of the locations input argument.
locations:
[{“address”:“Stratemakersveste 7, Arnhem”,“lat”:“51.944183168583265”,“lng”:“5.8522888008339029”},{“address”:“Spoordijk 8, Staphorst”,“lat”:“52.615909311957573”,“lng”:“6.2417455514837954”},{“address”:“Papekopperdijk1 / Hogebrug, Papekop”,“lat”:“52.040796021740633”,“lng”:“4.8417212064734638”},{“address”:“Spoordijk 3, Heukelom”,“lat”:“51.571771503906803”,“lng”:“5.1497328563086251”},{“address”:“Knoevenoordstraat 3, Brummen”,“lat”:“52.099297487035557”,“lng”:“6.1498974393968391”},{“address”:“Parallelweg 19, Sliedrecht”,“lat”:“51.832969772618505”,“lng”:“4.763065453190281”}]
req = POST(url2, authenticate(username, password) ,…)
How do i finish the statement above using locations as input the correct way?
UPDATE: I was able to solve it using the httr2 library:
url2 = ‘https://api.routexl.com/tour’
req ← request(url2) |> req_auth_basic(username, password)
req %>% req_dry_run() # test
req ← req %>% req_body_form(locations = locations)
resp ← resp_body_json(req_perform(req))