Page 1 of 1

Error 415 when posting to /login

Posted: Fri Oct 05, 2018 2:56 pm
by Assyrial
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?

Re: Error 415 when posting to /login

Posted: Mon May 13, 2019 10:04 am
by adrianleverseidge
Did you figure this out? I'm stuck with the exact same problem in vscode.

Re: Error 415 when posting to /login

Posted: Tue May 14, 2019 5:28 pm
by szsori
Can you include a header for "Accept: application/json" and see if that works?

Re: Error 415 when posting to /login

Posted: Thu May 16, 2019 6:13 pm
by Reprevise
I have tried adding an accept header and it still doesn't work.

Re: Error 415 when posting to /login

Posted: Mon Jun 17, 2019 2:19 pm
by pete
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?