Failed to parse response of the method

Failed to parse response of the method


Hi everyone,

So i try to consume a REST API
and somehow i always got this error


Hello Eric,

Is the REST webservice you're trying to consume returning JSON or XML (like SOAP webservices)?
As far as I know, (but I may be wrong), The "test" in the consume dialog will not work with XML.

If this is the case, I think the only way to make it work from inside OutSystems (without resorting to an Extension), is doing the following (be arned, I didn't tested this).

1. Consume the method WITHOUT testing. It will create the method, without any Output parameter.
2. Create the output structure manually and add an Output parameter of this type to the method.
3. Change the response type in the method to Text JSON
4. Add an OnAfterResponse method to the consumed WbeService.
5. In the method, get the plain text answer (in XML), and convert it to JSON, to the same format of your output structure, and return this as the output of the OnAfterResponse.

If someone knows a better way, I would like to learn :)

Alos, if this is not the problem, could you put here the reponse that you are expecting?


EDIT. By the way, are you sure it is a REST web service?


Hello Eric.

Assuming you verified that indeed the problem is that this is a REST that returns the response as a XML...

Usually we COPY the Response into the CustomizedResponse, and change in the last what we want (that will be what OutSystems will use to create the output of the method.

So, in your case, you will have to change whatever you received in the Response.ResponseText to a valid JSON (one that can be mapped to your output structure (of the method).

Just a correction about the answer above, you don't need to change the Response type to Text. You can set it to JSON.