Error Code 1010 calling POST translate

I’m using some Javascript to call the Translate API using XMLHttpRequest and I’m getting an error code 1010 returned.
I have a Content-Type header set of ‘aplication/json’; are there other header requirements?

Mm, are you able to make a request by simply visiting ?

Yes, it works fine in the browser

Here is my JS snippet (the input1[0] etc are passed into the process from a controlling app)


var params = “?q=” + input1[0] + “&source=” + input1[1] + “&target=” + input1[2] + “&format=” + input1[3] + “&api_key=” + input1[4];
var url = “” + encodeURI(params);
var xmlHttp = new XMLHttpRequest();“POST”, url, false);

var output1 = “” + xmlHttp.responseXML;

I would try to pass the parameters as POST body parameters rather than with query parameters (?q= …). Also, is the code running from the same network as your browser (or is it running on a server somewhere else?)

I’ll try the body parameters. Code is on the same network as the browser

I tried the following, sending the parameters as body. Still Error Code 1010 I’m afraid.


var json = {
“q”: + input1[0],
“source”: input1[1],
“target”: input1[2],
“format”: input1[3],
“api_key”: input1[4]

var xhr = new XMLHttpRequest();“POST”, “”, false);

var output1 = “” + xhr.responseXML;

I think error 1010 could be a Cloudflare error, uses Cloudflare.

1 Like

Details on resolving 1010 from CloudFlare. This suggests changes at the LibreTranslate end can resolve this. However, as I’m calling programmatically rather than via a browser, it may be that I need to be sending additional headers or somesuch?


@argosopentech thanks for the lead. The latest change has certainly moved the needle with a User-agent header seeming to please CloudFlare and get me through to the endpoint



Thanks for sharing the solution!

That’s really strange of cloudflare; we didn’t set any blocking rules for user-agent. It looks like they might be blocking user-agent-less requests by default?