Поддержка 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 ответов (на странице 1 из 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

Не можете найти фильм или сериал? Войдите на сайт, чтобы добавить его.

Глобальные

s фокусироваться на панели поиска
p открыть меню профиля
esc закрыть открытое окно
? открыть окно сочетаний клавиш

На страницах медиа

b назад (или выше, если применимо)
e перейти на страницу правки

На страницах сезонов

(стрелка вправо) перейти к следующему сезону
(стрелка влево) перейти к предыдущему сезону

На страницах эпизодов

(стрелка вправо) перейти к следующему эпизоду
(стрелка влево) перейти к предыдущему эпизоду

На всех страницах изображений

a открыть окно добавления изображения

На всех страницах правки

t открыть переключатель переводов
ctrl+ s отправить форму

На страницах обсуждения

n создать новое обсуждение
w сменить статус отслеживания
p публичное/приватное
c закрыть/открыть
a открыть страницу действий
r ответить в обсуждении
l перейти к последнему ответу
ctrl+ enter отправить своё сообщение
(стрелка вправо) следующая страница
(стрелка влево) предыдущая страница

Параметры

Хотите поставить оценку или добавить в список?

Войти