webwrite to query web API data issue
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I used webwrite to query web API data, when I use below code, it works well.
url = 'https://open.lixinger.com/api/a/index';
options = weboptions('RequestMethod','post','ContentType','json');
token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'; %% my Web API token
stockcode = ["000016", "399986"]; %% this is to define stockcode string array!
request_body = struct("token", token, "stockCodes", stockcode);
response = webwrite(url, request_body, options);
BUT when i try to use only one stockcode, query works but no data in it. no errors.
url = 'https://open.lixinger.com/api/a/index';
options = weboptions('RequestMethod','post','ContentType','json');
token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'; %% my Web API token
stockcode = "000016"; %% I only use one stockcode here!!! it not work!! seems this definition is not exactly same as above.
request_body = struct("token", token, "stockCodes", stockcode);
response = webwrite(url, request_body, options); %% there is respose but no data in it.
https://open.lixinger.com/api/a/index Web API request parameter "stockCodes" is Array type.
anyone can help on this?
appreciate!!!
1 comentario
Hans Scharler
el 4 de Oct. de 2023
I can't replicate the API interaction since the API no longer exists, but it looks like you were very close. "webwrite" is the way to go: https://www.mathworks.com/help/matlab/ref/webwrite.html
Respuestas (0)
Ver también
Categorías
Más información sobre Web Services en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!