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 个评论

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

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Creating, Deleting, and Querying Graphics Objects 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by