Error 414 when trying to send base64 image through URL


#1

Hello,
I am trying to send a base64 image through the url but it keeps giving me “Error 414 Request URL is too Long”.
I am using javascript in a mobile development platform called Kony.
I implemented sending image through URL in GET and it is working perfectly.

request.open(constants.HTTP_METHOD_POST, "https://api.ocr.space/parse/image?apikey=" + apiKey + "&base64Image=data:image/jpeg;base64," + this.view.camera.base64 + "&filetype=JPG", false);

request.setRequestHeader("Content-type","image/jpg");

I am using the image taken from the phone camera as base64. I made sure that the type is JPG.
Please provide help if you can. Thanks in advance.


#2

Does the same request work in Postman?


#3

I am sorry for the late reply.
The same request doesn’t work in Postman too. I tried different image sizes.
On medium sized images I get Error 414 Request URL is too long and on small images I get Error 400 header too long.


#4

If it does not work in Postman, then my guess is that something is wrong with your base64 string. How big is the image? And how long the string? If you generate a base64 string from a small image, does it work then?


#5

The image is about 20kb and in base64 is 32k characters.
The small image in base64 is 16k characters.

In medium image I get error 414 request url is too long.
In small image I get error 400 header too long.


#6

…it seems something is wrong with your base64 string. You can test your string with one of the online base64 converter tools, for example https://codebeautify.org/base64-to-image-converter

And here is a base64 string that works:

data:image/jpeg;base64,/9j/4AAQSkZJRgABAAEAYABgAAD//gAfTEVBRCBUZWNobm9sb2dpZXMgSW5jLiBWMS4wMQD/2wCEAAUFBQgFCAwHBwwMCQkJDA0MDAwMDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0BBQgICgcKDAcHDA0MCgwNDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDf/EAaIAAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKCwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoLEAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4O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