Adeel
Adeel

Reputation: 415

Why RESTful web service choose XML instead of JSON if we give both in produces list?

I have a RESTful web service that produces both XML and JSON. But when I give both in produces list such as

@Produces({"application/json","application/xml"})

It only produces XML when I run it in a browser. So my question does XML is default or high priority than the other ?

Upvotes: 0

Views: 2560

Answers (1)

Sukma Wardana
Sukma Wardana

Reputation: 550

You can delete the application/xml since I doubt that you need that and it will return JSON as response even on your browser, but if you really need that application/xml I suggest you to test your REST API using REST Client such as Postman or just simple curl and specify on your header request:

Content-Type: application/json
Accept: application/json

Upvotes: 1

Related Questions