Can't parse the JSON response from an api or define schema

Usually this is super simple but I’m struggling with the response from an API. It has a simple ping function to test the connection and authorisation etc is working fine. It simply returns a message with Hello appended as a prefix.

I have a server connect called ping taking an input, digitally signing and calling the api. All works well and I can see the response in the console but I can’t parse the JSON no matter what I’ve tried.

This is what I send:

This is the response in the console:

If I try to define the schema in Wappler, this is what I get:
image

Note that “data” is being seen as a text field and there’s nothing under it.

If I try coding the expressions manually, I get this:

The path to just the data shows the whole string correctly but trying to call “message” directly, or trying toJSON or parseJSON all throw the same error "cannot use ‘in’ operator to search for ‘message’:

Has anyone come across this before or got any ideas how I can work with the response? I can’t see why Wappler has a problem reading it.

Node server on Docker (digital ocean).

Thanks all

OK I figured out a solution in case this happens to anyone else. No idea why Wappler doesn’t parse it as usual but you can manually convert the JSON string to a JSON object in the server action and then it works.

image

Need to make sure data type is object

image

Then you can use the results in the server connect as usual. If you define the schema it will be available in the UI as well

The remote API is not returning the correct Content-Type header (should be JSON). Instead, it’s reporting as HTML, making Wappler skip implicit JSON parsing and instead treating data as a literal string.

Your workaround consists on parsing that string as JSON.