I'm using the javascript library.
There's no way to remove a movie from that list:
Passing the movie_watchlist = false doesn't work.
It returns always a 201 code (success) and the movie is not removed. (Even though In the api doc, there is 200 as a successful response).
I've tried several methods, passing the parameter as query or in the body, but no way.
The example the api doc provides doesn't work, returning some errors about cross-domain issues.
Here is the request
Request URL:http://api.themoviedb.org/3/account/xxxx/movie_watchlist?api_key=xxxx
Request Method:POST
Status Code:201 Created
Request Headers
Accept:application/json, text/javascript, */*; q=0.01
Accept-Encoding:gzip,deflate,sdch
Accept-Language:it,en-US;q=0.8,en;q=0.6,ja;q=0.4,fr;q=0.2,it-IT;q=0.2,zh-CN;q=0.2,zh;q=0.2
Connection:keep-alive
Content-Length:89
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Host:api.themoviedb.org
Origin:http://localhost:8888
Referer:http://localhost:8888/xxx
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36
Query String Parameters
api_key:xxx
Form Dataview
session_id:xxx
movie_id:251519
movie_watchlist:false
Even if it is not strictly as indicated in the api doc, it works in adding, but fails in removing.
Thanks Andrea
P.S.: thanks for your GREAT work!
Can't find a movie or TV show? Login to create it.
Want to rate or add this item to a list?
Not a member?
Reply by Travis Bell
on April 22, 2014 at 9:46 PM
Hi Andrea,
I'm out of the office tomorrow but will look into this on Thursday. Thanks.
Reply by Travis Bell
on April 25, 2014 at 1:11 PM
Hi Andrea,
I can't quite seem to replicate this. These 4 calls add and remove the items properly for me:
Are you posting the JSON as a body data?
Reply by panurge_ws
on April 25, 2014 at 9:38 PM
Hi Travis,
thank you. Yes I've tried several ways but I can't make it.
here is the javascprit code (exactly copied from the doc):
Here the network log from Chrome:
As you can see, following that method I get a 404 error. Quite strange.... (session_id is correctly authorized and the account id is right, becaus i can retrieve the items from the lists).
Andrea
Reply by panurge_ws
on April 26, 2014 at 6:51 AM
As a side note, here is the code that I use to add a move to favorite (with success). It's a jquery ajax call:
where the body data is:
Here is the network log:
As you can see, it returns a status 201 created. Avoiding to set the request header content type to "application/json", it performs a correct POST request, but it doesn't send properly a json object in the body but a Form Data object. Differently from the example in the previous reply (copied from the api doc), this one has an apparent success... BUT, using the same code with a favorite = false, it returns the same result (and the same status code) without removing the movie from the favorite list.
In few words, the strange thing is that even if passing a not well formed (according to the api doc) json in body data of the request, the server side can read the movie_id and add it to the favorite list as well. But passing a false value for "favorite" it doesn't work. In the other hand, if you pass a correct header "content type" and "accept", and the json as body data, you have a bad request as posted in the previous reply.
I hope this can help.
Andrea
Reply by shinta187
on April 28, 2014 at 9:10 AM
Was about to post the same problem. Removing an item from the watchlist has the same issue as removing an item from the favorite list. Has this already been looked into?
Thank you very much.
Reply by Travis Bell
on April 28, 2014 at 1:29 PM
Turns out this was 2 things, one of which required an addition to the API.
First, while we support JSONP for GET requests, we don't truly for POST. In these examples, jQuery was attempting to make an OPTIONS call to the API first to see what remote CORS calls it is allowed to make. So I added a valid OPTIONS method for the API calls that need it. A local HTTP call through something like cURL doesn't require this.
Second, you weren't serializing your JSON properly. You need to pass a valid JSON object back to the server. I put a working session example online which you can see here. You can see on line 50, you need to make sure to
JSON.parse(OBJECT)
so that you're sending valid JSON.Cheers.
Reply by panurge_ws
on April 28, 2014 at 6:56 PM
Thank you, Travis.
Now everything is working properly. Tested in favorite and in watch_list.
Thanks again for your support and for your great work.
A.
Reply by shinta187
on August 7, 2014 at 8:55 AM
Hi again,
The call for making a movie favorite does work curl -H "Content-Type: application/json" -d '{"media_id":"240832","media_type":"movie","favorite":"true"}' -X POST "http://api.themoviedb.org/3/account/ACCOUNTID/favorite?api_key=YOURAPIKEY&session_id=YOURSESSIONID".
unfortunately the remove from favorites does not work with curl: curl -H "Content-Type: application/json" -d '{"media_id":"240832","media_type":"movie","favorite":"false"}' -X POST "http://api.themoviedb.org/3/account/ACCOUNTID/favorite?api_key=YOURAPIKEY&session_id=YOURSESSIONID".
It does say: The item/record was updated successfully. but it doesn't update the record for some reason...
I can't figure it out, it is the same call with one property changed.... Can someone help?
Kind regards,
Johnny
Reply by Travis Bell
on August 7, 2014 at 9:57 AM
Hi shinta187,
Can you see the difference if you pass the "true" / "false" in as an actual boolean and not a string? Ie.
Let me know.
Reply by shinta187
on August 7, 2014 at 10:44 AM
Hi Travis,
That did the trick, thanks alot, it works now in curl. Working on a movies app as well. If the app is done, can i send you guys a message so that the app can be featured on the site after review?
Kind Regards
Reply by Travis Bell
on August 7, 2014 at 4:17 PM
Yup, for sure. We usually look for apps that feature more functionality than not (ie. account and/or session features, maybe use of discover). You can email travis@themoviedb.org when you're ready.