webread
Read content from url using Rest API
Attention: Valid only with Altair Communication Extension.
Syntax
response = webread(url)
response = webread(url,options)
Inputs
- url
- URL address
- options
- web options. output of weboptions.
Outputs
- response
- content read from web service specified by url.
Examples
read content from url
url = 'http://ergast.com/api/f1/2004/1/results.json';
data = webread(url);
datajson = jsondecode(data);
Driver = datajson.MRData.RaceTable.Races.Results(1).Driver
Driver = struct [
code: MSC
dateOfBirth: 1969-01-03
driverId: michael_schumacher
familyName: Schumacher
givenName: Michael
nationality: German
url: http:\/\/en.wikipedia.org\/wiki\/Michael_Schumacher
read content from url with query string
url = 'https://api.restful-api.dev/objects';
data_full = webread(url);
data = webread(url,'id','3')
data = [{"id":"3","name":"Apple iPhone 12 Pro Max","data":{"color":"Cloudy White","capacity GB":512}}]
read content from url with web options
url = 'https://httpbin.org/get';
options = weboptions('Username','testuser','Password','testpassword','RequestMethod','get','HeaderFields',struct('Content-Type','application/json'));
res = webread(url,options)
res = {
"args": {},
"headers": {
"Accept": "*/*",
"Authorization": "Basic dGVzdHVzZXI6dGVzdHBhc3N3b3Jk",
"Content-Type": "application/json",
"Host": "httpbin.org",
"X-Amzn-Trace-Id": "Root=1-656e65bd-6928e1c72b9d5a8e68f62c61"
},
"origin": "68.61.253.8",
"url": "https://httpbin.org/get"
}