Adam Johns
Adam Johns

Reputation: 36373

Should requests and responses to web services be encoded the same?

For example if I send up a request as x-www-form-urlencoded is it considered bad practice to send back json from my web service? Should I also be sending up my request as json if I am sending json back?

Upvotes: 0

Views: 27

Answers (1)

Bogdan
Bogdan

Reputation: 24590

Technically speaking, it does not matter, since the server and client can negotiate the media types. If both client and server can handle the media types, then it's fine.

However, most of the times the same mime type is used for both requests and responses because it's easier for developers to reason about the web service's API and might also be easier to implement since you have only one type of representation to handle. Use whatever makes sense and is pertinent to the use case you are having.

Upvotes: 1

Related Questions