Post OCR request to server

Getting into LiveCode for iOS? Ask your questions here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
Posts: 130
Joined: Fri Oct 14, 2011 6:53 am

Post OCR request to server

Post by » Wed Dec 02, 2015 11:38 am

Can anyone help me?
I try to send a jpg file to "" for OCR reading. I use the following code but I get "Error 400 Bad Request" all the time.
Now I have tried everything, and find myself just scroll up and down in the code at random, evidently hoping that the error will correct itself.

I have used similar code to post pictures from my iOS device, or from any platform, in fact, to my own server and that works just fine.
But in that case, I have the set the parameters I want to use my self, so that it is significantly easier.

What have I missed?

/// Peter

function buildIt
put "-----------------------------7de2ec26c059e" & crlf into tData
put "Content-Disposition: form-data name=; apikey" & crlf after tData
put MyApikey & crlf after tData
put "-----------------------------7de2ec26c059e" & crlf after tData
put "Content-Disposition: form-data name=; language" & crlf after tData
put sv & crlf after tData
put "-----------------------------7de2ec26c059e" & crlf after tData
put "Content-Disposition: form-data name =; image" & crlf after tData
put "Content-Type: image/jpg" & crlf after tData
put tPic & crlf after tData
put crlf & "-----------------------------7de2ec26c059e--" & crlf after tData
get the number of chars of tData
put it into tLength
put buildHeader() into theHeader
set the httpHeaders to theHeader
put tData into msg
return tData
end buildIt

function buildHeader
put "Accept: text/html, application/xhtml+xml, */*" & cr into temp
put "Accept-Encoding: gzip, deflate" & cr after temp
put "Accept-Language: sv-SE,sv;q=0.5" & cr after temp
put "User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko" & cr after temp
put "Content-Type: multipart/form-data; boundary=" & "---------------------------7de2ec26c059e" & cr after temp
put "Connection: Keep-Alive" & cr after temp
put "Content-Length: " & tLength & cr after temp
put "DNT: 1" & cr after temp
put "Referer:" & cr after temp
put "Pragma: no-cache" & cr after temp
return temp
end buildHeader
/*Whats all the fuss with c# ?*/

Post Reply

Return to “iOS Deployment”