How do you process the data received from API in ND-JSON format?

It is just for security

Are you going to show your raw responseContent, which will contain the error message ?

Now there is not response at all:

is there a space after Bearer?
in case both the token and game id are correct, these blocks should work...
Taifun

There is a space between Bearer and the token. The token is correct.
I must to remark that I can receive correct response (JSON response) for another requests from the API. The problem is with ND-JSON response (streaming data)

The response is definitely ND-JSON format. In the uploaded picture of the terminal I show only begining of the streaming response.

try logcat to find out what is going on

Taifun


ndjson test

I received a list of JSON objects, joined by \n separators.

Splitting at \n gave me a list of JSON objects that look ready for the web block that decodes JSON as dictionaries.

2 Likes

I received a list of JSON objects, joined by \n separators.

Splitting at \n gave me a list of JSON objects that look ready for the web block that decodes JSON as dictionaries.
[/quote]

I replicated it but no response at all

And if you specify user neio?

I logged on to lichess.org and set up an account for myself, then did two puzzles.

I generated a personal token that only has permission to see the puzzles that I did, and
pasted the token into a block.

It worked the first time:

So I am guessing you need to add a token or have overstayed your welcome at lichess.org

Thank you very much for the effort ABG. I already have a Token and user name but I think that the problem is with the smartphone. I tested the app in an emulator and it works. What could be the problem with my device? I tested in another device without success.

For me it works with companion. Check documentation for response type, for example users public data is in json format

I found the solution in order to make it work in my smartphone after app installation.
I added the following block:

Now it works.

Thanks for telling us the solution.

I am not happy with AI2's lack of error reporting for this case.

Would you mind exposing the Web1.GotText responseCode value for the case where INTERNET permission is denied?

Also include a Web1.Timeout event to announce if that fired under those circumstances?

Screen1.PermissionDenied event?

Screen1.ErrorOccured?

"Internet" is a non dangerous permission and usually therefore you do not have to ask for that permission

Which Android device and Android version are you using for your tests?

Taifun

I thought that I solved the problem but I did not. When the ndjson response start and end I can read it but the problem is when the response is streaming without end, the block Web1.GotText get stuck and can not even read responseCode.
For example with request for https://lichess.org/api/tv/feed
The response is streaming of ndjson

I've never seen AI2 used in an online streaming situation.
Has any one else on the board seen or done this?

Can someone help to display streaming of text?

What does the api documentation say about handling the stream?

What happens if you make the call in a webview (html) and set the "stream" to a div (which you could then set to a webviewstring at intervals). You could test this in a computer browser...

You would probably need javascript and "fetch", but may hit CORS errors...

Some ideas here