API call from postman to Matlab.

11 Ansichten (letzte 30 Tage)
Dion Theunissen
Dion Theunissen am 18 Jan. 2022
Beantwortet: Vinod am 19 Jan. 2022
I want to make an API call. I converted the script to a python code but can not make it to convert it to an matlab example.
I tried to use this link without any succes: https://nl.mathworks.com/help/thingspeak/readdata.html
Can Anyone help me how to request this API with the header?
HTTP:
GET /rfms2/vehiclestatuses?vin=YS2R6X20005376392&dateType=received&startTime=2022-01-12T00:00:00&stopTime=2022-01-12T23:59:59 HTTP/1.1
Host: dataaccess.scania.com
Accept: application/vnd.fmsstandard.com.VehicleStatuses.v2.1+json; UTF-8
Authorization: Bearer ****
Content-Type: application/json
Content-Length: 27
{"query":"","variables":{}}
Python:
import requests
import json
url = "https://dataaccess.scania.com/rfms2/vehiclestatuses?vin=YS2R6X20005376392&dateType=received&startTime=2022-01-12T00:00:00&stopTime=2022-01-12T23:59:59"
payload="{\"query\":\"\",\"variables\":{}}"
headers = {
'Accept': 'application/vnd.fmsstandard.com.VehicleStatuses.v2.1+json; UTF-8',
'Authorization': 'Bearer ****',
'Content-Type': 'application/json'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
Thanks

Antworten (1)

Vinod
Vinod am 19 Jan. 2022
I think you will find this documentation helpful: https://www.mathworks.com/help/matlab/ref/webread.html

Kategorien

Mehr zu Call Python from MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by