Error 415 when posting to /login

A place for developers to advertise their TheTVDB.com enabled app and get help from other developers with the API.
Post Reply
Assyrial
Posts: 1
Joined: Fri Oct 05, 2018 12:50 pm

Fri Oct 05, 2018 12:56 pm

Hi guys,

I'm making this side project but i'm getting this 'error 415 unsupported media type' everytime i post to https://api.thetvdb.com/login. I'm using fetch to post to it. My code:


let myHeaders = new Headers();
myHeaders.append("Content-Type","application/json")

let myInit = { method: 'POST',
headers: myHeaders,
mode: 'no-cors',
body: JSON.stringify({
"apikey":"My_API_Key",
"username":"My_Username",
"userkey":"My_Userkey"
})
};

let myRequest = new Request('https://api.thetvdb.com/login', myInit);

fetch(myRequest).then(function(response) {
console.log(response);
}).catch(err=>console.error(err))

Any of you had this problem or know what i'm doing wrong?
adrianleverseidge
Posts: 1
Joined: Mon May 13, 2019 8:02 am

Mon May 13, 2019 8:04 am

Did you figure this out? I'm stuck with the exact same problem in vscode.
User avatar
szsori
Site Admin
Posts: 2190
Joined: Fri Nov 03, 2006 2:23 pm

Tue May 14, 2019 3:28 pm

Can you include a header for "Accept: application/json" and see if that works?
Reprevise
Posts: 1
Joined: Thu May 16, 2019 4:12 pm

Thu May 16, 2019 4:13 pm

I have tried adding an accept header and it still doesn't work.
pete
Posts: 1
Joined: Mon Jun 17, 2019 12:18 pm

Mon Jun 17, 2019 12:19 pm

You need to provide a header of Content-Type: application/json to get around this error, I can see your code includes it but is it being passed?
Post Reply