API call from postman to Matlab.

7 vues (au cours des 30 derniers jours)
Dion Theunissen
Dion Theunissen le 18 Jan 2022
Réponse apportée : Vinod le 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

Réponses (1)

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

Catégories

En savoir plus sur Call MATLAB from Python dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by