webwrite to query web API data issue

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 commentaire

Hans Scharler
Hans Scharler le 4 Oct 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

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by