The Movie Database Support

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 replies (on page 1 of 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...?

Can't find a movie or TV show? Login to create it.

Global

s focus the search bar
p open profile menu
esc close an open window
? open keyboard shortcut window

On media pages

b go back (or to parent when applicable)
e go to edit page

On TV season pages

(right arrow) go to next season
(left arrow) go to previous season

On TV episode pages

(right arrow) go to next episode
(left arrow) go to previous episode

On all image pages

a open add image window

On all edit pages

t open translation selector
ctrl+ s submit form

On discussion pages

n create new discussion
w toggle watching status
p toggle public/private
c toggle close/open
a open activity
r reply to discussion
l go to last reply
ctrl+ enter submit your message
(right arrow) next page
(left arrow) previous page

Settings

Want to rate or add this item to a list?

Login