REST API returns malformed JSON

api

#1

I’m trying to get the list of someone’s followers.
But REST API sometimes returns malformed JSON which cannot be parsed as usual, so my app stops every time even I decrease the “count” parameter.
This is a REAL returned data from REST API which crashes my app.
https://gist.github.com/nao20010128nao/9922801226373270b1b419e5e048df0d


#2

Are you able to provide the API call and parameters that produces that response, please?

What are you using to parse the JSON inside your app?


#3

API call is this (this is not a call when I posted, but it also returns malformed JSON):

GET followers/list?user_id=783214&count=50&cursor=1541075414351958046

I can’t dump the response because Wireshark doesn’t work well.

The library to parse the JSON is Newtonsoft.Json (used by CoreTweet).


#4

I’ve just tried this using twurl and the response from that call seems to parse OK in JSONlint. I don’t see anything that breaks at the moment.

I can see that there is a malformed element in the raw.json file in your first post. However, I’m confused as to how you generated that JSON document - what tool or app are you using? If this is your own app, can you share the app ID (not the consumer keys), please?

Basically I’m struggling to reproduce this reliably.


#5

Also, in your original post, the Tweet that appears to have “malformed” content which breaks the parser appears to be Tweet ID 758307575939133440 (please confirm that this matches your analysis?) - I can successfully pull that individual Tweet from the API and do not see this issue.


#6

Umm…

This is the code of the request of CoreTweet(used by my app)


And this is the app ID of my app: 12278991


#7

I’m still unable to reproduce this issue with a specific Tweet or API response that contains a malformed element. I accept that the JSON you’ve posted at the top of this thread is not valid, but I cannot recreate it.