Help with new line characters in API response \r\n

I have a simple Wappler API GET request which outputs fine in Node.JS
But exactly the same request with the server model as PHP causes issues.
Both return the same JSON in the Wappler Schema editor, no problem at all.
But the PHP output contains \r\n \ everywhere when opened in the browser.

The server is a local OSX Mamp Pro, so if there is anything I need to change here, any help would be appreciated.

Thanks in advance.

I think it may be this "data":"\ufeff{\r\n

I know this may not be a Wappler generated issue and probably a MAMP/Apache setting somewhere.
If anyone has an idea of what I can check so that the Server Action API returns escaped newline characters in the response like it does using the Node.JS server model, that would really be appreciated. :+1:

Sorry for another post, I made the switch from classic asp to node.js and for this I needed to host the pages in php, so if I have something wrong with the configuration any pointers would be appreciated.

Both the same server connect in ASP or NODE.JS work fine, so if there is an extra step in PHP to work with escape characters, then can someone help?

Thanks

Am I missing something obvious here? If so apologies in advance.
I have deployed to Docker rather than local MAMP and it is the same response with PHP. I have created a set value step to remove \r\n and that isn’t doing anything.
I have also tested a couple of other API endpoints including https://jsonplaceholder.typicode.com and I cannot bind that data. (See below Wappler SC open in browser)

{"api":{"status":200,"headers":{"0":"HTTP\/2 200","date":"Thu, 07 Oct 2021 09:49:47 GMT","content-type":"application\/json; charset=utf-8","x-powered-by":"Express","x-ratelimit-limit":"1000","x-ratelimit-remaining":"999","x-ratelimit-reset":"1633135892","vary":"Origin, Accept-Encoding","access-control-allow-credentials":"true","cache-control":"max-age=43200","pragma":"no-cache","expires":"-1","x-content-type-options":"nosniff","etag":"W\/\"53-hfEnumeNh6YirfjyjaujcOPPT+s\"","via":"1.1 vegur","cf-cache-status":"HIT","age":"3493","expect-ct":"max-age=604800, report-uri=\"https:\/\/report-uri.cloudflare.com\/cdn-cgi\/beacon\/expect-ct\"","report-to":"{\"endpoints\":[{\"url\":\"https:\\\/\\\/a.nel.cloudflare.com\\\/report\\\/v3?s=Kz%2BRj7KZ8B4B7fOF6OegA2HEYNoZCI3punr8CjMU38jKHOieHWHtY1kgmogr0%2Fkcu8aWkJR7KA5Mh%2BW6t2Le5EvwJLcrqlQR23ClyLKeUIGIUz%2B7gJ8N0nsHKsBG3WaVDEfV56RAPUKBePD3PpuX\"}],\"group\":\"cf-nel\",\"max_age\":604800}","nel":"{\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}","server":"cloudflare","cf-ray":"69a638b3db645403-LHR","content-encoding":"gzip","alt-svc":"h3=\":443\"; ma=86400, h3-29=\":443\"; ma=86400, h3-28=\":443\"; ma=86400, h3-27=\":443\"; ma=86400"},"data":{"userId":1,"id":1,"title":"delectus aut autem","completed":false}}}

Any ideas at all @patrick?

What exactly is the api returning, it seems that it is not a valid json and it then returns the data as it was received.

That looks like a BOM (https://en.wikipedia.org/wiki/Byte_order_mark).

Try the following update, unzip in dmxConnectLib/modules.

api.zip (2.8 KB)

Thanks @patrick, but that file replacement now errors with:

code":0,"file":"\/Users\/dev\/Sites\/localhost\/dmxConnectLib\/modules\/api.php","line":267,"message":"json_decode() expects at least 1 argument, 0 given"

Oh, my error, did some last minute code change and accidentally removed an argument there. Hope I didn’t mess up again, here new update.

api.zip (2.8 KB)

1 Like

Wonderful, thanks @patrick

Hi @patrick, are you able to include this fix in future builds?

This has been fixed in Wappler 4.2.1

1 Like

This topic was automatically closed after 46 hours. New replies are no longer allowed.