Suport de The Movie Database

Hi there, I have an issue with my API Key. If I search a "top rated" with basicFetch(/trending/all/week?language=pt-BR&api_key${API_KEY}) but, receive "items: {status_code: 7, status_message: "Invalid API key: You must be granted a valid key.", success: false" someone can help me?

10 resposta (a les pàgines 1 de 1)

Jump to last post

same problem

@Kaimzr said:

Hi there, I have an issue with my API Key. If I search a "top rated" with basicFetch(/trending/all/week?language=pt-BR&api_key${API_KEY})

Assuming you aren't putting an = in your API_KEY var (which seems unlikely), you're missing the HTML delimiter:

/trending/all/week?language=pt-BR&api_key=${API_KEY}

Would be what you're looking for.

Travis, Thanks for your reply, however the persistent error. and yes, i have a const with my api_key.

What’s is the full request that isn’t working?

Follow my code;

const API_KEY = '77e9fa013xxxxxxxxxxxxxx';
const API_BASE = 'https://api.themoviedb.org/3';

const basicFetch = async (endpoint) => {
    const req = await fetch(`${API_BASE}${endpoint}`);
    const json = await req.json();
    return json;
}

export default {
getHomeList: async () => {
    return [
        {
        slug: 'originals',
        title: 'Originais do Netflix',
        items:await basicFetch(`/discover/tv?with_network=213&language=pt-BRapi_key=${API_KEY}`)

},
   {
        slug: 'trending',
        title: 'recomendados para Você',
        items: await basicFetch(`/trending/all/week?language=pt-BR&api_key=${API_KEY}`)
   },
   {
    slug: 'toprated',
    title: 'em alta',
    items: await basicFetch(`/movie/top_rated?language=pt-BR&api_key=${API_KEY}`)
   }, 
   {
    slug: 'action',
    title: 'Ação',
    items: await basicFetch(`/discover/movi?with_genres=28&language=pt-BR&api_key=${API_KEY}`)
   }, 
   {
    slug: 'comedy',
    title: 'comedia',
    items: await basicFetch (`/discover/movi?with_genres=35&language=pt-BR&api_key=${API_KEY}`)
   }, 
   {
    slug: 'horror',
    title: 'terror',
    items: await basicFetch (`/discover/movi?with_genres=27&language=pt-BR&api_key=${API_KEY}`)
   }, 
   {
    slug: 'romance',
    title: 'romance',
    items: await basicFetch (`/discover/movi?with_genres=10749&language=pt-BR&api_key=${API_KEY}`)
   }, 
   {
    slug: 'documentary',
    title: 'documentarios',
    items: await basicFetch (`/discover/movi?with_genres=99&language=pt-BR&api_key=${API_KEY}`)
   }, 
];
}
}

all requests return me, error 401 and 404, and say my api key is invalid.

@Kaimzr said:

Follow my code;

all requests return me, error 401 and 404, and say my api key is invalid.

I believe there are some characters missing from your Requests.
Always put your API Key after the " ? "
Try building your API Request with this other sequence:

title: 'Originais do Netflix',
https://api.themoviedb.org/3/discover/tv?with_network=213&language=pt-BRapi_key=${API_KEY}`)
https://api.themoviedb.org/3/discover/tv?api_key=THE_KEY&language=pt-BR&with_networks=213
You forgot the & character before with_network=

title: 'recomendados para Você',
https://api.themoviedb.org/3/trending/all/week?language=pt-BR&api_key=${API_KEY}`)
https://api.themoviedb.org/3/trending/all/week?api_key=THE_KEY
In trending it is not possible to specify the language (pt-BR).

title: 'em alta',
https://api.themoviedb.org/3/movie/top_rated?language=pt-BR&api_key=${API_KEY}`)
https://api.themoviedb.org/3/movie/top_rated?api_key=THE_KEY&language=pt-BR
You forgot the & character before language=

title: 'terror',
https://api.themoviedb.org/3/discover/movi?with_genres=27&language=pt-BR&api_key=${API_KEY}`)
https://api.themoviedb.org/3/discover/movie?api_key=THE_KEY&language=pt-BR&with_genres=27
In this case you wrote movi, that is, movie without the " e " character at the end.

There are probably some other minor errors. :-)

@ticao2 said:

@Kaimzr said:

Follow my code;

all requests return me, error 401 and 404, and say my api key is invalid.

I believe there are some characters missing from your Requests.
Always put your API Key after the " ? "
Try building your API Request with this other sequence:

title: 'Originais do Netflix',
https://api.themoviedb.org/3/discover/tv?with_network=213&language=pt-BRapi_key=${API_KEY}`)
https://api.themoviedb.org/3/discover/tv?api_key=THE_KEY&language=pt-BR&with_networks=213
You forgot the & character before with_network=

title: 'recomendados para Você',
https://api.themoviedb.org/3/trending/all/week?language=pt-BR&api_key=${API_KEY}`)
https://api.themoviedb.org/3/trending/all/week?api_key=THE_KEY
In trending it is not possible to specify the language (pt-BR).

title: 'em alta',
https://api.themoviedb.org/3/movie/top_rated?language=pt-BR&api_key=${API_KEY}`)
https://api.themoviedb.org/3/movie/top_rated?api_key=THE_KEY&language=pt-BR
You forgot the & character before language=

title: 'terror',
https://api.themoviedb.org/3/discover/movi?with_genres=27&language=pt-BR&api_key=${API_KEY}`)
https://api.themoviedb.org/3/discover/movie?api_key=THE_KEY&language=pt-BR&with_genres=27
In this case you wrote movi, that is, movie without the " e " character at the end.

There are probably some other minor errors. :-)

tnx man

@Kaimzr said:

A curiosity of mine, I speak pt-BR.
You are the 4 user who speaks pt-BR that comes here in the last 10 days with the same problem.
Are you taking any code programming course that uses API?
Is it a school or online?
Can you say the name of the course, where it is, etc...?

@bukqueiroz said:

tnx man

A curiosity of mine, I speak pt-BR.
You are the 4 user who speaks pt-BR that comes here in the last 10 days with the same problem.
Are you taking any code programming course that uses API?
Is it a school or online?
Can you say the name of the course, where it is, etc...?

No trobeu una pel·lícula o una sèrie? Inicieu la sessió per a crear-la.

Global

s centra la barra de cerca
p obre el menú del perfil
esc tanca una finestra oberta
? obre la finestra de dreceres de teclat

A les pàgines de materials

b torna enrere (o la superior quan sigui aplicable)
e ves a la pàgina d'edició

A les pàgines de temporades

(fletxa dreta) ves a la temporada següent
(fletxa esquerra) ves a la temporada anterior

A les pàgines d'episodis

(fletxa dreta) ves a l'episodi següent
(fletxa esquerra) ves a l'episodi anterior

A totes les pàgines d'imatges

a obre la finestra d'afegir imatges

A totes les pàgines d'edició

t obre el selector de traducció
ctrl+ s envia el formulari

A les pàgines de debat

n crea un debat nou
w canvia l'estat de visualització
p canvia públic/privat
c tanca o obre
a obre activitat
r resposta al debat
l ves a la darrera resposta
ctrl+ enter envieu el vostre missatge
(fletxa dreta) pàgina següent
(fletxa esquerra) pàgina anterior

Configuracions

Desitgeu valorar o afegir aquest element a una llista?

Inicieu la sessió