Assistance de TMDB

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 réponses (sur la page 1 sur 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

Un film, une émission télévisée ou un artiste est introuvable ? Connectez-vous afin de créer une nouvelle fiche.

Général

s Mettre le curseur dans la barre de recherche
p Ouvrir le menu du profil
esc Fermer une fenêtre ouverte
? Ouvrir la fenêtre des raccourcis clavier

Sur les pages des médias

b Retour (ou vers le parent si faisable)
e Afficher la page de modification

Sur les pages des saisons des émissions télévisées

Afficher la saison suivante (flèche droite)
Afficher la saison précédente (flèche gauche)

Sur les pages des épisodes des émissions télévisées

Afficher l'épisode suivant (flèche droite)
Afficher l'épisode précédent (flèche gauche)

Sur toutes les pages des images / photos

a Ouvrir la fenêtre d'ajout d'image / photo

Sur toutes les pages de modifications

t Ouvrir le sélecteur de traduction
ctrl+ s Envoyer le formulaire

Sur les pages des discussions

n Créer une nouvelle discussion
w Basculer le statut de suivi
p Basculer publique / privée
c Basculer fermer / ouvrir
a Ouvrir l'activité
r Répondre à la discussion
l Afficher la dernière réponse
ctrl+ enter Envoyer votre message
Page suivante (flèche droite)
Page précédente (flèche gauche)

Paramètres

Vous souhaitez évaluer ou ajouter cet élément à une liste ?

Connexion