Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erro Detran PR #5

Open
marcelobue opened this issue Jul 23, 2024 · 0 comments
Open

Erro Detran PR #5

marcelobue opened this issue Jul 23, 2024 · 0 comments

Comments

@marcelobue
Copy link

marcelobue commented Jul 23, 2024

Boa noite,
Por favor poderia verificar ao tentar realizar a requisição na API para o Detran PR eu recebo esta mensagem
{
"message": "Não foi possível fazer login no DETRAN PR",
"error": "Request failed with status code 401"
}

Verificando o código vejo que está caindo na exception do Try da linha 19 do arquivo.

constructor() {
this.index = async (req, res) => {
const renavam = req.body.renavam;
if (!renavam.match(/^[0-9]+$/)) {
return res.status(400).json({ message: 'Renavam inválido' });
}
const multas = await this.scrap(renavam);
res.status(200).json(multas);
};
this.scrap = async (renavam) => {
try {
const payload = await utils_1.default.request(${process.env.PR_URL}/?renavam=${renavam}, 'GET', {
'Accept-Charset': 'UTF-8',
'Accept-Encoding': 'gzip',
'Access-Control-Allow-Headers': 'Content-Type, Content-Range, Content-Disposition, Content-Description, Origin, X-Requested-With, Accept',
'Access-Control-Allow-Methods': 'GET, PUT, POST, DELETE, OPTIONS',
'Access-Control-Allow-Origin': '*',
'Connection': 'Keep-Alive',
'Host': 'www.wsutils.detran.pr.gov.br',
'User-Agent': 'Dalvik/2.1.0 (Linux; U; Android 9; SM-G973N Build/PQ3A.190605.05171606)',
'Version': '1.1.5',
'X-Date': ${new Date().toISOString()}
}, null);
const response = payload;
return response;
}
catch (e) {
return { message: 'Não foi possível fazer login no DETRAN PR', error: e.message };
}
};
}

Para estados como MG, AL, PB consegui realizar a requisição sem maiores problemas.

Obrigado

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant