Problem with webreading using webread and weboption

14 ビュー (過去 30 日間)
faran
faran 2018 年 11 月 16 日
コメント済み: faran 2018 年 11 月 19 日
I have a link which I need to read information from it and write my info in the web. I used the codes below:
url = 'http://abc/rest_api/qc_steps.json'; (abc is just an example)
options = weboptions('RequestMethod', 'post', 'ArrayFormat','json');
data = webread(url,options)
I get this error:
Error using readContentFromWebService (line 45)
The server returned the status 500 with message "Internal Server Error : An error occurred (23000): SQLSTATE[23000]: Integrity constraint violation: 1048
Column 'field_qc_step_image_ref_target_id' cannot be null" in response to the request to URL
http://abc/rest_api/qc_steps.json.
which "field_qc_step_image_ref_target_id" is an information in the link. But I don't know how to solve it! Can anyone help?
  1 件のコメント
faran
faran 2018 年 11 月 16 日
I have this information too.
{
"userId":1,
"slideId":530,
"qcStep":{
"index":"background-scoring",
"value":"rejected",
"selected":{
"index":"0.50"
}
}
}
which I thinnk I need to put it on webread, but I get this error:
data = webread(url,'userId','1','slideId','530','index','background-scoring','value','rejected','index','0.50');
Error using readContentFromWebService (line 45)
The server returned the status 404 with message "Not found : Could not find the controller." in response to the request to URL
http://abc/rest_api/qc_steps.json?userId=1&slideId=530&index=background-scoring&value=rejected&index=0.50.

サインインしてコメントする。

採用された回答

Hitesh Kumar Dasika
Hitesh Kumar Dasika 2018 年 11 月 19 日
Please try using webwrite instead of webread as you are trying to send HTTP POST request to the mentioned server. webread is usually used for HTTP GET Requests.
webwrite provides options to put the data in the request as request body and send unlike webread.
  1 件のコメント
faran
faran 2018 年 11 月 19 日
Thanks, It worked.
options = weboptions('RequestMethod', 'post', 'ArrayFormat','json','MediaType','application/json');
datainfo.userId=1;
datainfo.slideId=532;
qcStep.index='background-scoring';
qcStep.value='rejected';
selected.index=0.5;
qcStep.selected=selected;
datainfo.qcStep=qcStep;
response = webwrite(url,datainfo,options)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWeb Services についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by