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

API: Cannot save statement contains Vietnamese characters via API #543

Open
emeralddd opened this issue May 13, 2024 · 0 comments
Open

API: Cannot save statement contains Vietnamese characters via API #543

emeralddd opened this issue May 13, 2024 · 0 comments

Comments

@emeralddd
Copy link

I have recently tried API of Polygon. All things worked correctly until I found I couldn't update statements containing some special Vietnamese characters (eg: ê, ô, ...).

This is my code:

const { default: axios } = require('axios');
const { sha512 } = require('js-sha512');

const a = async () => {
    const key = "xxx";
    const secret = "yyy";

    const date = Math.floor(new Date().getTime() / 1000);
    const rand = 100000 + Math.floor(Math.random() * 900000);

    const apiSig = sha512(`${rand}/problem.saveStatement?apiKey=${key}&lang=english&legend=ê&problemId=351173&time=${date}#${secret}`);

    const req = await axios.post(`https://polygon.codeforces.com/api/problem.saveStatement?apiKey=${key}&lang=english&legend=${encodeURIComponent('ê')}&problemId=351173&time=${date}&apiSig=${rand}${apiSig}`);

    console.log(req.data);
}
a();

Nodejs 20.11.1
Axios 1.6.8

After I had sent the request, I got the error message: "Incorrect signature". Everything worked normally when I removed all the special Vietnamese characters.

So is it a bug or am I wrong in any step?

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