Assistance de TMDB

I'm getting this error with jQuery (I was able to create the list with PHP):

OPTIONS https://api.themoviedb.org/4/list 401 (Unauthorized) XMLHttpRequest cannot load https://api.themoviedb.org/4/list. Response for preflight has invalid HTTP status code 401

Someone help me?

jQuery does not work

var settings = {
                'async': true,
                'crossDomain': true,
                'url': 'https://api.themoviedb.org/4/lists',
                'method': 'POST',
                'headers': {
                    'authorization': 'Bearer  TOKENxxXxxxxXxxXXx',
                    'content-type': 'application/json;charset=utf-8'
                },
                'processData': false,
                'data':  "{\"name\":\"My Cool List\",\"iso_639_1\":\"en\"}"
            };
            $.ajax(settings).done(function (response) {
                console.log(response);
            });

PHP Works

function create_list($access_token) {
    $curl = curl_init();
    curl_setopt_array($curl, array(
        CURLOPT_URL => "https://api.themoviedb.org/4/list",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => "",
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 30,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_POSTFIELDS => "{\"name\":\"My Cool List\",\"iso_639_1\":\"en\"}",
        CURLOPT_HTTPHEADER => array(
            "authorization: Bearer $access_token",
            "content-type: application/json;charset=utf-8"
        ),
    ));
    $response = curl_exec($curl);
    $err = curl_error($curl);
    curl_close($curl);
    if ($err) {
        echo "cURL Error #:" . $err;
    } else {
        return json_decode($response);
    }
}

14 réponses (sur la page 1 sur 1)

Jump to last post

I can get this fixed. I need to add the pre-flight options in. I'll see about getting this done this weekend.

Nice, thanks man grin

Im having an issue related to "pre-flight" not sure if its the same thing or not -- but there wasn't a response to my post so I just thought I would bring it up here.

https://www.themoviedb.org/talk/58bd25a1c3a368666b045066

Thanks,

Fixes for this should be live.

I pushed 2 small test scripts to verify all of this which can be seen here:

@travisbell said:

Fixes for this should be live.

I pushed 2 small test scripts to verify all of this which can be seen here:

(Edited) It works! My first test failed because I put my token and not access token, sorry and thanks!

Make sure you're authorising a new token with write privileges from a user account. You can use my auth script above to do that.

I've walked through the entire process with those 2 scripts and can guarantee it works.

@travisbell said:

Make sure you're authorising a new token with write privileges from a user account. You can use my auth script above to do that.

I've walked through the entire process with those 2 scripts and can guarantee it works.

Nice! I failed haha, thanks.

thumbsup wink

@travisbell said:

Make sure you're authorising a new token with write privileges from a user account. You can use my auth script above to do that.

I've walked through the entire process with those 2 scripts and can guarantee it works.

Travis, I'm getting this error when I try do delete the list. (Other methods are working).

XMLHttpRequest cannot load https://api.themoviedb.org/4/list/20096. Method DELETE is not allowed by Access-Control-Allow-Methods in preflight response.

Give it a try now.

According to this spec doc, the wildcard (*) value I was using before doesn't work in Chrome or Firefox. It seemed fine in Safari (my main browser) so I didn't see this issue.

@travisbell said:

Give it a try now.

According to this spec doc, the wildcard (*) value I was using before doesn't work in Chrome or Firefox. It seemed fine in Safari (my main browser) so I didn't see this issue.

It works! Thanks!

Travis, could you check the other list and account methods as well?

Look:

XMLHttpRequest cannot load https://api.themoviedb.org/4/account/{account_id}/lists?{}. Response for preflight has invalid HTTP status code 500
XMLHttpRequest cannot load https://api.themoviedb.org/4/account/{account_id}/tv/favorites?{}. Response for preflight has invalid HTTP status code 500
XMLHttpRequest cannot load https://api.themoviedb.org/4/account/{account_id}/movie/favorites?{}. Response for preflight has invalid HTTP status code 500

Ok, not sure why those OPTIONS requests are failing but I'll look into it shortly.

@travisbell said:

Ok, not sure why those OPTIONS requests are failing but I'll look into it shortly.

Thanks man!

Give those requests a try now. Should be good to go.

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