weboptions and webwrite alternative for MATLAB 2009

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
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.
I'm sorry I'm new to MATLAB. Does urlread support all versions? Could you provide an alternate snippet to the one which I have posted which works on all versions of MATLAB?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Rik
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
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.

Melden Sie sich an, um zu kommentieren.

Produkte

Version

R2009b

Gefragt:

am 14 Dez. 2018

Kommentiert:

Rik
am 19 Dez. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by