Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

unsupported media type rest error

While hitting ewbserive using chrome advanced rest client getting eror as below for post and put request if i do not select "application/xml" from drop down.

unsupported media type error

i wonder why i ahve to select that value as
"application/xml"

delete also not working
insgtead of giving 200 OK giving 204 no content even though it seems deleting successfully

please advise
RestAPI.png
RestAPI2.png
RestAPI3.png
delete126.png
delete126_2.png
delete126_3.png
delete126_4.png
Avatar of HainKurt
HainKurt
Flag of Canada image

I dont see whats wrong here...
check the documentation for that service and send what it expects...
guddi9 who developed the service? You need to check the service to see what the behaviour is.

1-I believe the default content-type is text/plain, so setting it to application/xml means the service only accepts xml. Please check the service.
2-returning a 204 on a delete is what I would expect.

in conclusion - if you're testing your own web service (running on localhost), you should know what it is doing.
Avatar of gudii9

ASKER

no complete solution yet
Avatar of gudii9

ASKER

2-returning a 204 on a delete is what I would expect.
why do you expect 204 for delete? please advise
Guddi9 this is as per Rest/http spec.
Please read into response codes.
Avatar of gudii9

ASKER

Guddi9 this is as per Rest/http spec.
Please read into response codes.
can you please point me to the Rest/http spec direct link

my search goes broader as below
https://www.google.com/search?rlz=1C1CHBF_enUS734US734&q=+http+rest+spec&oq=+http+rest+spec&gs_l=psy-ab.3..0i20k1j0i8i30k1j0i8i10i30k1j0i30k1.30873.31127.0.31695.3.3.0.0.0.0.273.273.2-1.1.0....0...1.1.64.psy-ab..2.1.273.xVr98TFzXV8
ASKER CERTIFIED SOLUTION
Avatar of gurpsbassi
gurpsbassi
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Remember this is a convention and not a rule. So if the API developer chose to return a 204 instead of 200, it's fine. And vice versa.

My personal preference is to return a 204 on a delete since I wouldn't expose the entity in the response.
Avatar of gudii9

ASKER

Remember this is a convention and not a rule. So if the API developer chose to return a 204 instead of 200, it's fine. And vice versa.

which API developers? REST API developers? it cannot be changed by us right only REST developers from one release to other release?
Guddi9 - I can't answer your question until you answer mine.
 I asked you
who developed the service?
Avatar of gudii9

ASKER

i do not know i am just trying some examples from internet
Guddi9 - So I can Interpret that as the service was not developed by Guddi9.

In which case, you are consuming someone else rest service ? correct?
In which case, you have to live with the fact that they are responding with a 204 and not a 200.

Can this question be closed now?