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 comentarios

Rik
Rik el 14 de Dic. de 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?

Iniciar sesión para comentar.

Respuestas (1)

Rik
Rik el 14 de Dic. de 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 comentario

Rik
Rik el 19 de Dic. de 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.

Iniciar sesión para comentar.

Productos

Versión

R2009b

Preguntada:

el 14 de Dic. de 2018

Comentada:

Rik
el 19 de Dic. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by