weboptions and webwrite alternative for MATLAB 2009
Show older comments
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 Comments
Rik
on 14 Dec 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
on 14 Dec 2018
Answers (1)
Rik
on 14 Dec 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 Comment
Rik
on 19 Dec 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.
Categories
Find more on Web Services in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!