The Movie Database Support

Hi,

Probably a dumb question but I'll ask anyway as I can't get it to work... how can I add or remove an item from the watchlist using the raw data method. I've tried all sorts of combinations, read and re-read the documentation and Googled for answers but not had any luck yet.

https://api.themoviedb.org/3/account/{id}/watchlist?api_key=XXXX&session_id=XXXX{"media_type": "movie","media_id": 127585,"watchlist": false}

Any help or a working example would be gratefully appreciated.

Thanks

7 replies (on page 1 of 1)

Jump to last post

No one gonna throw me a bone :(

Hey Ben,

You need to POST the data in as JSON. In cURL, an working example looks like:

curl -H "Accept: application/json" -H "Content-Type: application/json" \
-d "{'media_type': 'movie', 'media_id': 550, 'watchlist': true}" \
"https://api.themoviedb.org/3/account/{ID}/watchlist?api_key=###&session_id=###"

Hi Travis,

Thanks for the reply... I still don't get it but I'll go read up and see if I can learn more.

Thanks

What language are you coding in?

VB.NET, I tried the example but it doesn't work for me. Not had time this week to find out why.

The error I get is: The 'Accept' header must be modified using the appropriate property or method.

And the code I'm using looks like:

Dim request = TryCast(System.Net.WebRequest.Create("https://api.themoviedb.org/3/account/{id}/watchlist?api_key=xxxx&session_id=xxxx"), System.Net.HttpWebRequest)
request.Method = "POST"
request.ContentType = "application/json"
request.Headers.Add("Content-Type", "application/json")
request.Headers.Add("Accept", "application/json")
Using writer = New System.IO.StreamWriter(request.GetRequestStream())
  Dim byteArray As Byte() = System.Text.Encoding.UTF8.GetBytes("{\n    \""media_type\"": \""movie\"",\n    \""media_id\"": 11,\n    \""watchlist\"": true\n}")
  request.ContentLength = byteArray.Length
  writer.Write(byteArray)
  writer.Close()
End Using
Dim responseContent As String
Using response = TryCast(request.GetResponse(), System.Net.HttpWebResponse)
  Using reader = New System.IO.StreamReader(response.GetResponseStream())
    responseContent = reader.ReadToEnd()
  End Using
End Using

I got it sorted in the end... just for future reference or anyone else who needs a nudge in the right direction I've added my code below.


        Dim apiKey As String = "XXX"
        Dim sessionID As String = "XXX"
        Dim jsonEncoding As String = "{" & vbLf & "    ""media_type"": ""movie""," & vbLf & "    ""media_id"": 127585," & vbLf & "    ""watchlist"": true" & vbLf & "}"

        Try

            Dim client As New Net.WebClient
            client.Headers.Add("Content-Type", "application/json")
            client.Headers.Add("Accept", "application/json")

            Dim responsebytes = client.UploadData("https://api.themoviedb.org/3/account/{id}/watchlist?api_key=" & apiKey & "&session_id=" & sessionID, _
            "POST", System.Text.Encoding.UTF8.GetBytes(jsonEncoding))

        Catch webex As WebException
            MsgBox(webex.Message)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

Thanks

Ben

Can't find a movie or TV show? Login to create it.

Global

s focus the search bar
p open profile menu
esc close an open window
? open keyboard shortcut window

On media pages

b go back (or to parent when applicable)
e go to edit page

On TV season pages

(right arrow) go to next season
(left arrow) go to previous season

On TV episode pages

(right arrow) go to next episode
(left arrow) go to previous episode

On all image pages

a open add image window

On all edit pages

t open translation selector
ctrl+ s submit form

On discussion pages

n create new discussion
w toggle watching status
p toggle public/private
c toggle close/open
a open activity
r reply to discussion
l go to last reply
ctrl+ enter submit your message
(right arrow) next page
(left arrow) previous page

Settings

Want to rate or add this item to a list?

లాగిన్