kkkkgyg
kkkkgyg

Reputation: 131

Postman Mock Server Response Body

I created a mock server using Postman, then I accessed the server url, I got HTML response body. However, I want JSON response body.

What do I have to do?

enter image description here

enter image description here

Upvotes: 5

Views: 4285

Answers (1)

Danny Dainton
Danny Dainton

Reputation: 25921

To get the correctly formatted response, you need to include the Content-Type header in the response section of the Example.

This is what the Mock Server response looks like without the header:

Without Content-Type header

Open the Example and add the header to the bottom response section, you may see the Body tab shown when you open the Example, switch tabs to Headers, add the header and save the Example.

Adding the Header

With the header added, send the request to the Mock Server, this will return the correctly formatted response based on the Content-Type header.

With the Content-Type header

Upvotes: 9

Related Questions