HERE RESTful API - POST - Fleet Telematics

6 vues (au cours des 30 derniers jours)
Sridhar Eswaran
Sridhar Eswaran le 24 Juin 2020
Commenté : Sridhar Eswaran le 29 Juin 2020
Hi, How can I send this request in matlab?
/////
curl --location --request POST 'https://fleet.cit.api.here.com/2/calculateroute.json?routeMatch=1&mode=car&app_id=ABCDEFGHIJK&app_code=ABCDEFGHIJK&attributes=ROAD_GEOM_FCn(*),%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 (http://www.benichou-software.com)" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/0" xmlns:topografix="http://www.topografix.com/GPX/Private/TopoGrafix/0/2" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd http://www.topografix.com/GPX/Private/TopoGrafix/0/2 http://www.topografix.com/GPX/Private/TopoGrafix/0/2/topografix.xsd"><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 = 'https://fleet.cit.api.here.com/2/calculateroute.json?routeMatch=1&mode=car&app_id=ABCDEFGHIJK&app_code=ABCDEFGHIJK &attributes=ROAD_GEOM_FCn(*),SPEED_LIMITS_FCn(*)';
weboptions('ContentType','text','RequestMethod','POST')
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
https://fleet.cit.api.here.com/2/calculateroute.json?routeMatch=1&mode=car&app_id=ABCDEFGHIJK&app_code=ABCDEFGHIJK&attributes=ROAD_GEOM_FCn%28%2A%29,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.

Réponse acceptée

Geoff Hayes
Geoff Hayes le 24 Juin 2020
Sridhar - the 400 error code indicates (if I recall correctly) that there is a problem with your request. I see that you call
weboptions('ContentType','text','RequestMethod','POST')
but that you don't do anything with the result of that call. I think that your code could be more like
url = 'https://fleet.cit.api.here.com/2/calculateroute.json?routeMatch=1&mode=car&app_id=ABCDEFGHIJK&app_code=ABCDEFGHIJK &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.
  7 commentaires
Geoff Hayes
Geoff Hayes le 26 Juin 2020
Hi Sridhar - I tried with the above code using system and it worked so long a valid app code and id were used.
Sridhar Eswaran
Sridhar Eswaran le 29 Juin 2020
Hi Geoff, I will reacquire a new app id, app code and try your suggestion. Will let you know the outcome. Thanks

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Software Development Tools dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by