API returns plain text. How to process it on server side?

Hi guys,

Anyone worked with APIs that return plain text?

Example: https://api.pwnedpasswords.com/range/0F3FB

How would you deal with it to perform some checks on server connect against a value sent in a form? I need to hash the input password, send the 5 first characters from the hash to the API via URL(0F3FB in the example), retrieve the contents, search in the response for the full hash password and return to the form info.

I am specially interested in the API part.

Thanks in advance.

I’ve searched the forum but was only able to find this

@George @patrick

I see it’s still assigned. Is this something pending?

We only work with json sources normally and aren’t going to add parsers for other content formats. I have added some autodetection to the API action so that it should return the raw data as string when it doesn’t have a json content-type header, which is in your case probably exactly what you want. You then have to parse the string content yourself. Please test if it works.

DMXzone.ServerConnect.API.zip (6.5 KB)

2 Likes

Precisely. I confirm it works. I can now process the api.data object with the raw text.

Thanks Patrick!

I’ve got the same issue - how do I install these ZIP files patrick ?

Thanks

I can’t confirm this is the case but changes like this would usually be integrated into the next update so I would expect this to already be part of Wappler.

Unfortunately not. The callbacks (from daily co teleconferencing) are JSON but the content type is text/plain. As a result, wappler isn’t processing them.

I’ve replicates the post entirely using postman and changing to JSON works.

Thanks

I’m having the same problem. Wappler can not parse non Json Format while fetch schema process.
How can we solve this issue?
I am having a problem retrieving data from an API Source GET.
Screenshot 2022-11-04 223246

No data has been set under data after Fetch Schema
Screenshot 2022-11-04 231502

Screenshot 2022-11-04 231635

Well that’s not a valid JSON that’s why we cannot fetch the schema. The ok: JSON follows part should not be there. This won’t really validate in any JSON validator out there.

1 Like

Ok than do you have an idea how to parse this plain string text into array.
I did split text after ok:JSON follows.(it has been removed by “set value splittedtext = api.data.split(‘follows’)[1])” at server side.

Below attached sample data after split;(Do you have an example parser for this multiple row values into an array?)
{
“status”: “OK”,
“data”:
[
{ “value1”: 1, “value2”: “test”, “value3”: 11, “value4”: “valueresult”, “value5”: “11.22.33.44” }
{ “value1”: 2, “value2”: “test”, “value3”: 22, “value4”: “valueresult”, “value5”: “11.22.33.45” }
{ “value1”: 3, “value2”: “test”, “value3”: 33, “value4”: “valueresult”, “value5”: “11.22.33.46” }
{ “value1”: 4, “value2”: “test”, “value3”: 44, “value4”: “valueresult”, “value5”: “11.22.33.47” }
{ “value1”: 5, “value2”: “test”, “value3”: 55, “value4”: “valueresult”, “value5”: “11.22.33.48” }
]
}

set value results = api.data.split(‘follows’)[1].parseJSON()

Wappler will not recognize the data correctly since it doesn’t know what the results contains. So with the data picker it probably will not show as an array.

1 Like