Webwrite in json format not working

I was trying to write to an server using REST API. I tried it using POSTMAN it was working. The data i am trying to write is in json format. I gave Content type as json and Mediatype as application/json. requestmethod as post. The erro message is "The srver returned the status 415 with message unsupported media type".

댓글 수: 4

Guillaume
Guillaume 2019년 7월 10일
We would need to see at least what code you're using and probably the data you're sending.
Hari Krishna Ravuri
Hari Krishna Ravuri 2019년 7월 16일
Hi,
I understood that, you are trying to write JSON data to a server which is running REST API. You have mentioned that, it is working fine with POSTMAN; So I’m assuming that the server application is working fine. Coming to the “Error 415”, this is probably due to setting wrong parameters or trying to send the JSON data which has wrong format. Please provide the code by which you are trying to send the data, so that a possible solution can be provided.
Hi,
As you have asked the code is as follows
Obj=weboptions
Obj.Username='DEMO';
Obj.Password='DEMO';
Obj.ContentType='json';
Obj.MediaType='application/json';
Obj.ArrayFormat='json';
Mea=struct('Name','Result','mimetype','','name','LinearFit','dataType','Array','unit','NA','mimeType','','dataValues',Regression_Results.Fitted);
webwrite('Link',Mea,Obj);
Note :
Regression_Results.Fitted is a vector of data type double.
I am not allowed to share the link where i am posting the data so it is given as link
Guillaume
Guillaume 2019년 7월 24일
Can you also show the working json that you sent via postman?
Is it correct that you have both a mimetype and a mimeType property and both a Name and name property in your JSON? It's unusual to have properties that differ just by case (and horrendous design!)

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

제품

릴리스

R2019a

태그

질문:

2019년 7월 10일

댓글:

2019년 7월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by