Suporte do The Movie Database

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 respostas (na página 1 de 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

Não consegue encontrar um certo filme ou série? Inicie sessão e adicione-o.

Geral

s focus the search bar
p abrir menu do perfil
esc close an open window
? open keyboard shortcut window

Em páginas de Média

b go back (or to parent when applicable)
e ir para a página de edição

Em páginas de temporadas de séries

(seta para a direita) ir para a próxima temporada
(seta para a esquerda) ir para a temporada anterior

Em Páginas de Episódios de Séries

(seta para a direita) ir para o próximo episódio
(seta para a esquerda) ir para o episódio anterior

Em Todas as Páginas de Imagens

a abrir janela para adicionar imagem

Em Todas as Páginas de Edição

t open translation selector
ctrl+ s submit form

Em Páginas de Discussão

n criar uma nova discussão
w toggle watching status
p toggle public/private
c toggle close/open
a abrir actividade
r reply to discussion
l ir para a última resposta
ctrl+ enter submit your message
(seta para a direita) página seguinte
(seta para a esquerda) página anterior

Definições

Deseja classificar ou adicionar este item a uma lista?

Iniciar Sessão

Ainda não é um membro?

Crie uma Conta e Adere a Comunidade