MATLAB Answers

HERE RESTful API - POST - Fleet Telematics

5 views (last 30 days)
Hi, How can I send this request in matlab?
curl --location --request POST '*),%0ASPEED_LIMITS_FCn(*)' \
--header 'Content-Type: text/plain' \
--data-raw '<?xml version="1.0" encoding="UTF-8" standalone="no"?><gpx version="1.0" creator="ITN Converter 1.94M (" xmlns:xsi="" xmlns="" xmlns:topografix="" xsi:schemaLocation=""><time>2020-06-22T11:22:23Z</time><bounds minlat="49.274710" minlon="9.223330" maxlat="49.288730" maxlon="9.242580"/><rte><name>Route_from_Peter</name><rtept lat="49.274710" lon="9.223330"/><rtept lat="49.274740" lon="9.223380"/><rtept lat="49.274840" lon="9.223540"/><rtept lat="49.275030" lon="9.223830"/><rtept lat="49.275160" lon="9.224100"/><rtept lat="49.275260" lon="9.224290"/>...........................<rtept lat="49.288230" lon="9.241680"/><rtept lat="49.288280" lon="9.241760"/><rtept lat="49.288340" lon="9.241850"/><rtept lat="49.288390" lon="9.241920"/><rtept lat="49.288440" lon="9.241990"/><rtept lat="49.288560" lon="9.242200"/><rtept lat="49.288730" lon="9.242580"/></rte></gpx>'
I have used this code,
url = ' &attributes=ROAD_GEOM_FCn(*),SPEED_LIMITS_FCn(*)';
payload = fileread('AudiRoute_Section01.gpx');
response = webwrite(url,payload);
The response was,
Error using matlab.internal.webservices.HTTPConnector/copyContentToByteArray (line 396)
The server returned the status 400 with message "" in response to the request to URL,SPEED_LIMITS_FCn%28%2A%29,ADAS_ATTRIB_FCn%28%2A%29,LINK_ATTRIBUTE_FCn%28%2A%29.
Error in readContentFromWebService (line 46)
byteArray = copyContentToByteArray(connection);
Error in webwrite (line 139)
[varargout{1:nargout}] = readContentFromWebService(connection, options);
Error in rest (line 4)
response = webwrite(url,payload);
Can anyone help here?
Thanks in Advance.

Accepted Answer

Geoff Hayes
Geoff Hayes on 24 Jun 2020
Sridhar - the 400 error code indicates (if I recall correctly) that there is a problem with your request. I see that you call
but that you don't do anything with the result of that call. I think that your code could be more like
url = ' &attributes=ROAD_GEOM_FCn(*),SPEED_LIMITS_FCn(*)';
options = weboptions('ContentType','text','RequestMethod','POST');
payload = fileread('AudiRoute_Section01.gpx');
response = webwrite(url,payload,options); % <--- include the options as a parameter of webwrite
I can't test the above so I don't know if it will work (especially with the payload) but it might get you a little further.
Sridhar Eswaran
Sridhar Eswaran on 29 Jun 2020
Hi Geoff, I will reacquire a new app id, app code and try your suggestion. Will let you know the outcome. Thanks

Sign in to comment.

More Answers (0)




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by