question

PavelBrokhman-0975 avatar image
0 Votes"
PavelBrokhman-0975 asked YuZhou-MSFT edited

MS Edge change GET Response to application/json

I recall that I could before REST API response result as JSON. Currently it shows me it as xml. Is there any settings in Edge browser that would help me to get Json instead Xml?

ms-edge
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

YuZhou-MSFT avatar image
0 Votes"
YuZhou-MSFT answered YuZhou-MSFT edited

Hi @PavelBrokhman-0975

When viewing a GET endpoint in a browser like Google Chrome, Firefox, or Microsoft Edge, the default Content-Type displayed in the browser is generally text/html in XML format. This is by design. I think what you should do is modify the code instead of trying to set the browser to solve it. You can use something like this :

 Content-Type: "application/json"

I found a good discussion on this issue, you can refer to it: How do I get ASP.NET Web API to return JSON instead of XML using Chrome?

Content-Type is decided by the REST API, you can't change it in browser. If you want to see JSON, you need to change it in the REST API.


If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Regards,
Yu Zhou

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

PavelBrokhman-0975 avatar image
0 Votes"
PavelBrokhman-0975 answered YuZhou-MSFT edited

I know how to develop in different languages. It wasn't the question. My question is simple. I want to see JSON when I use REST API in browser's url, not XML. Is it possible?

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @PavelBrokhman-0975

The HTTP response Content-Type header will be used to determine the content type and character encoding. When you do not set its content-type, the response result you get will default to text/html encoding and will be displayed in xml format. For more details, please refer to Http-Header-ContentType.

Content-Type is decided by the REST API, you can't change it in browser. If you want to see JSON, you need to change it in the REST API.

I've also edited my answer.

0 Votes 0 ·
PavelBrokhman-0975 avatar image
0 Votes"
PavelBrokhman-0975 answered

Following is the example of what I see. As you see this is a feed using XML. I want the same but JSON.

102516-image.png



image.png (24.1 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.