Base64 GET request not working outside of Postman

I am attempting to convert a Base64 image string in a JavaScript Chrome extension. I have gotten the request to work in Postman. However I am getting this error when request is implemented in code:

error TypeError: Failed to execute ‘fetch’ on ‘WorkerGlobalScope’: Request with GET/HEAD method cannot have body.

This error also occurs when using the code provided by Postman. According to the Mozilla docs the HTTP GET method should not have a body. However it seems like the OCR Space API only supports submitting the base64 string in a body for the GET method. Using it as a param results in a “URL too long” error.

Also, the curl request from this OCR Space Blog also does not work.

I haven’t seen anyone online or on this forum figure this issue out yet. Could someone please clarify how this works?

Here is my working request on Postman:


language, isOverlayRequired, OCREngine



I’ve tried this with all the example URLs as well

Here is the code provided by Postman that still does not work:

var myHeaders = new Headers()
myHeaders.append(“apikey”, apiKey)

var formdata = new FormData()
formdata.append(“base64image”, imageBase64)

var requestOptions = {
method: “GET”,
headers: myHeaders,
body: formdata,
redirect: “follow”,

endpoint (forum wont allow me to put in more than 2 links)”,
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.log(“error”, error))

BASE64 requests work only with the POST method.

The reason for this is that a URL is limited in length, and thus can not accept long base64 strings like base64Image=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD4AAAAW…

This is also mentioned in the ocr api docs:

The important limitation of the GET api endpoint is it only allows image and PDF submissions via the URL method, as only HTTP POST requests can supply additional data to the server in the message body. GET requests include all required data in the URL. So by design, a GET api cannot support file uploads (file parameter) or BASE64 strings (base64image ).

1 Like