API request WinHTTP or cURL

Did anyone mange to receive a response with cURL or WinHTTP?

cURL:
Authorization etc. works, I ?ve even copied the cURL line that you can copy from postman. I always get the error “No locations found”.

This is the code I ?ve tried in curl:
curl --request POST   --url https://api.routexl.nl/tour/ \
  --header ‘authorization: Basic blablabla’ \
  --header ‘content-type: multipart/form-data; boundary=—011000010111000001101001’ \
  --form ‘locations=[{“address”:“Start”,“lat”:“50.111512”,“lng”:“8.680506”},{“address”:“SAX15045538”,“lat”:“49.65228”,“lng”:“10.3277”},{“address”:“SAX15045849”,“lat”:“49.8177055”,“lng”:“10.3531641”},{“address”:“SAX15053738”,“lat”:“51.0496968”,“lng”:“6.2252342”},{“address”:“End”,“lat”:“50.111512”,“lng”:“8.680506”}]’

WinHTTP:

The problem here is that I can ?t find a way to tell WinHTTP where to put the request body with the locations.
This is the code I ?ve tried in C/AL:

CLEAR(winHTTP);
CREATE(winHTTP,FALSE,TRUE);
winHTTP.Open(‘POST’,'https://api.routexl.nl/tour/’) “Link https//apiroutexlnl/tour/”);
winHTTP.SetCredentials('myuser,‘mypassword’,0);
winHTTP.SetRequestHeader(‘Content-Type’,‘application/json’);
winHTTP.Send(‘locations=[{“address”:“Start”,“lat”:“50.111512”,“lng”:“8.680506”},{“address”:“SAX15045538”,“lat”:“49.65228”,“lng”:“10.3277”},{“address”:“SAX15045849”,“lat”:“49.8177055”,“lng”:“10.3531641”},{“address”:“SAX15053738”,“lat”:“51.0496968”,“lng”:“6.2252342”},{“address”:“End”,“lat”:“50.111512”,“lng”:“8.680506”}]’);

But same result here: “No locations found”

Any help would really be appreciated.

Thanks up front.

Thanks for the heads up. I saw the post too but didn ?t think that it could help me, but it did. It works with winHTTP now. The trick is indeed the urlencoded header. The body needs to be encoded as URL and not as a json array:

CLEAR(winHTTP);
CREATE(winHTTP,FALSE,TRUE);
winHTTP.Open(‘POST’,'https://api.routexl.nl/tour/’) “Link https//apiroutexlnl/tour/”);
winHTTP.SetCredentials('myuser,‘mypassword’,0);
winHTTP.SetRequestHeader(‘Content-type’,‘application/x-www-form-urlencoded; charset=utf-8’);
winHTTP.Send('locations=URLENCODEDADRESSES);

Hi there,

Not sure it helps but when testing with postman I switched the content-type to application/x-www-form-urlencoded and it worked for me.

Got the suggestion from another post on the support forums.

https://getsatisfaction.com/routexl/topics/409-conflict

Hope you manage to work it out.

Ah maybe that’s where I have been going wrong. Been trying to use ajax but keep getting a 401. Possibly down to that urlencoded factor.

Glad it’s working for you