API call from postman to Matlab.

19 次查看(过去 30 天)
Dion Theunissen
Dion Theunissen 2022-1-18
回答: Vinod 2022-1-19
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

回答(1 个)

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

类别

Help CenterFile Exchange 中查找有关 Call Python from MATLAB 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by