$(document).ready(function () { let url = "https://translate.yandex.net/api/v1.5/tr.json/detect?key=trnsl.1.1.20150402T131655Z.e753695703b45806.bda2fd6beb5bd56a62f0034352aaebbdba3f0952&text=hey"; let res = fetch(url, { method: 'POST', headers: new Headers({ 'Content-Type': 'application/x-www-form-urlencoded' }) }); }); This is my request. Looks like GET , right? The problem is that if I try to push at least one parameter into Body, the request returns a Bad Request .
let url = "https://translate.yandex.net/api/v1.5/tr.json/translate"; let res = fetch(url, { method: 'POST', body:JSON.stringify({key:"trnsl.1.1.20150402T131655Z.e753695703b45806.bda2fd6beb5bd56a62f0034352aaebbdba3f0952", lang:"en-ru", text:"hello"}), headers: new Headers({ 'Content-Type': 'application/x-www-form-urlencoded' }) }).then(ok=>console.log(ok.json())); There is an example in the documentation where the URL itself is with all the parameters except text . Okay, so I did. Still does not work:
let url = "https://translate.yandex.net/api/v1.5/tr.json/translate?key=trnsl.1.1.20150402T131655Z.e753695703b45806.bda2fd6beb5bd56a62f0034352aaebbdba3f0952&lang=en-ru"; let res = fetch(url, { method: 'POST', body:JSON.stringify({text:"hello"}), headers: new Headers({ 'Content-Type': 'application/x-www-form-urlencoded' }) }).then(ok=>console.log(ok.json())); I set the body explicitly, just like in their documentation :
let url = "https://translate.yandex.net/api/v1.5/tr.json/translate?key=trnsl.1.1.20150402T131655Z.e753695703b45806.bda2fd6beb5bd56a62f0034352aaebbdba3f0952&lang=en-ru"; let res = fetch(url, { method: 'POST', body:'text:hello', headers: new Headers({ 'Content-Type': 'application/x-www-form-urlencoded' }) }).then(ok=>console.log(ok.json())); You can check in the console. What am I doing wrong? I understand that in the POST parameters should be in the body, and not in the query string?
And this seems to be not a limitation in the number of characters - I still have not exactly reached 1 million