In the previous posts we talked a bit about how to create your REST Interfaces. Usually, when you are developing this kind of interfaces you use a JSON format in your payload. But, there is no default way to tell that to your API that the content-type that is replying is JSON. So, in this post I’m going to tell you how to do it.
First, we are going to talk with a first test to see the current problem. If I test our API we get this kind of response:
You can see the payload is a correct JSON string, but if you try to check it using the JSON tab inside the SOAPUI you are going to face this error message: “The content you are trying to view cannot be viewed as JSON”. That’s because as you can see we have not a Content-Type HTTP header that identify this payload as a JSON string.
But, we can change that inside our process, using the same way we use to map the output value from the process. Using the “Bind” button inside the REST Dispatch and Reply activity.
And the, after this change we can run a different test and check that now we have no problem trying to show the content as JSON String: