Comunidade
Erro 415 ao tentar código de Checkout...
Estou tentando integrar meu site ao pagseguro, estou tendo problemas ao tentar gerar o código de checkout, sempre retorna o erro 415. Mesmo eu copiando e colocando o exemplo da docs do pagseguro.
fornecendo mais informações...
fetch(
https://ws.sandbox.pagseguro.uol.com.br/v2/checkout?appID=${appID}&appKey=${appKey}
,
{
method: 'POST',
headers: {
accept: 'application/xml',
'content-type': 'application/json',
},
body: JSON.stringify({
currency: 'BRL',
'item: id': '01',
'item: description': 'teste',
'item: amount': '20',
'item: quantity': '1',
'item: weight': '1000',
'shipping: addressRequired': 'false',
}),
}
).then((response) => response.text());
exatamente igual ao exemplo da docs
também tentei....
fetch(
https://ws.sandbox.pagseguro.uol.com.br/v2/checkout?email=${email}&token=${token}
,
{
method: 'POST',
headers: {
accept: 'application/xml',
'content-type': 'application/json',
},
body: JSON.stringify({
currency: 'BRL',
'item: id': '01',
'item: description': 'teste',
'item: amount': '20',
'item: quantity': '1',
'item: weight': '1000',
'shipping: addressRequired': 'false',
}),
}
).then((response) => response.text());
console.log(teste);
return res.status(200).json(teste);
} catch (error) {
return res.status(200).json(error);
}
}
Resposta sempre a mesma...
JBossWeb/2.0.1.GA - Error report<style>
<!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}-->
</style>
HTTP Status 415 - Cannot consume content type
type Status report
message Cannot consume content type
description The server refused this request because the request entity is in a format not supported by the requested resource for the requested method (Cannot consume content type).
JBossWeb/2.0.1.GA