Error from webwrite on 201 response from server.

5 ビュー (過去 30 日間)
Troy Daniels
Troy Daniels 2016 年 9 月 9 日
コメント済み: Morrie Gasser 2016 年 11 月 23 日
I am using webwrite to make a post request. I can that the request is getting to the server and that the data is being sent. The server response with a 201 (Created) response. This appears to cause matlab to throw an error.
The call looks like
webwrite('http://localhost:9999/register', registerData, weboptions('MediaType', 'application/json'));
registerData is a struct.
Is there a way to tell matlab that 201 is a successful/expected response? Do I need to make the server respond with 200 (Ok) instead, even though 201 is a more accurate response?
The error message and stack trace is
Error using readContentFromWebService (line 37)
The server returned the message: "Created" for URL,
'http://localhost:9999/registerdbstack' (with HTTP response code 201).
Error in webwrite (line 126)
[varargout{1:nargout}] = readContentFromWebService(connection, options);
K>> dbstack
> In matlab.internal.webservices.HTTPConnector/copyContentToByteArray (line 235)
In readContentFromWebService (line 37)
In webwrite (line 126)
In myCode (line 83)
I am using Matlab 2015a (8.5.0.197613) on a 64-bit Mac.
Edit: add stack traces and version information
  4 件のコメント
Troy Daniels
Troy Daniels 2016 年 9 月 13 日
It appears that matlab has a bug in webwrite, where if the server returns a success code 2xx that is not 200, it is not possible to get the content returned by the web server.
Morrie Gasser
Morrie Gasser 2016 年 11 月 23 日
FWIW, this was fixed in R2015b. Any 2xx response code is considered success.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeCall Web Services from MATLAB Using HTTP についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by