weboptions and webwrite alternative for MATLAB 2009
Ältere Kommentare anzeigen
Below is how I access a REST API in MATLAB.
options = weboptions('Username', 'chankey007@gmail.com', 'Password', '********', 'RequestMethod', 'post', 'MediaType', 'application/xml');
payload = '<some_query>';
response = webwrite(url, payload, options);
But this doesn't work on MATLAB 2009 because weboption and webwrite were introduced in MATLAB 2014.
What would be the alternate way to make above work in MATLAB 2009?
2 Kommentare
Rik
am 14 Dez. 2018
Have you tried putting your payload in the get field? Weboptions might not exist, but urlread has several options in the name value pairs.
Chankey Pathak
am 14 Dez. 2018
Antworten (1)
Rik
am 14 Dez. 2018
Have you tried reading the documentation for that function? link
Also, being a POST or GET request doesn't matter for the choice between these functions. The only difference is that urlread will store the response in a char array and urlwrite stores the result in a file.
I don't know if this would work for every (or any) payload, but you could try something like the code below.
payload = '<some_query>';
[str,status] = urlread(url,...
'Username', 'chankey007@gmail.com',...
'Password', '********',...
'POST',{payload});
1 Kommentar
Rik
am 19 Dez. 2018
Did this suggestion solve your problem? If so, please consider marking it as accepted answer. It will make it easier for other people with the same question to find an answer. If this didn't solve your question, please comment with what problems you are still having.
Kategorien
Mehr zu Web Services finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!