twit
twit copied to clipboard
Got an error curating tweets. How can I add Tweets in bulk to a collection?
Hello, I'm testing your library and it's very useful, thank you.
However, I can't add Tweets in bulk to a collection with POST collections/entries/curate request. I got an error saying "malformed JSON body" with this params:
{"id":"custom-388061495298244609","changes":[{"op":"add","tweet_id":"390897780949925889"},{"op":"add","tweet_id":"390853164611555329"},{"op":"add","tweet_id":"390892747810295808"},{"op":"add","tweet_id":"390898463090561024"}]}
I think I've to set an explicit Content-Type of application/json or something like that, but I don't know how.
Do you know how can I make it works?
Thank you!
I'd recommend using Postman and trying the same request with the same payload. Also do set Content-Type: application/json in the headers.
I think the problem is that twit puts the request options in a URL querystring, and the querystring is malformed in this case. For example, when I am debugging one of my requests to curate, on line 103 of twitter.js, there is a call to self._doRestApiRequest with a reqOptions.url equal to:
https://api.twitter.com/1.1/collections/entries/curate.json?id=custom-1134340351794274304&changes=%5Bobject%20Object%5D%2C%5Bobject%20Object%5D%2C%5Bobject%20Object%5D%2C%5Bobject%20Object%5D
The params in the payload I am posting looks like this:
{ "id": "custom-1134340351794274304", "changes": [ { "op": "add", "tweet_id": "1334944482031185920" }, { "op": "add", "tweet_id": "1335267833782136833" }, { "op": "add", "tweet_id": "1335458212741435394" }, { "op": "add", "tweet_id": "1334945493634396160" } ] }
That querystring lost all the information contained in the payload.