Can anyone help me?
I try to send a jpg file to "http://api.ocrapiservice.com/1.0/rest/ocr" 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: http://api.ocrapiservice.com/1.0/rest/ocr" & cr after temp
put "Pragma: no-cache" & cr after temp
return temp
end buildHeader
Post OCR request to server
Getting into LiveCode for iOS? Ask your questions here.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 136
- Joined: Fri Oct 14, 2011 6:53 am
Post OCR request to server
Post by Peter@multidesk.se » Wed Dec 02, 2015 11:38 am
/*Whats all the fuss with c# ?*/
Jump to
- LiveCode Community
- ↳ Announcements
- ↳ Developer Services Marketplace
- ↳ User Groups and Events
- ↳ SoCal LiveCode Group
- ↳ Greater Toronto Area LiveCode Users Group
- ↳ Off-Topic
- ↳ Made With LiveCode
- Getting Started With LiveCode
- ↳ Getting Started with LiveCode - Complete Beginners
- ↳ Getting Started with LiveCode - Experienced Developers
- ↳ Converting to LiveCode
- ↳ App Building Course
- ↳ Simple Messages
- ↳ Calculator
- ↳ Notes
- ↳ Clock
- ↳ Web Browser
- ↳ Weather
- ↳ Compass
- ↳ Photos
- Developing With LiveCode
- ↳ Talking LiveCode
- ↳ Databases
- ↳ Games
- ↳ Internet
- ↳ Multimedia
- ↳ Software Engineering
- ↳ Version Control
- ↳ Feature Proposals
- ↳ Bug Triage
- ↳ Legacy Project: MetaCard
- Extending LiveCode
- ↳ Using Plugins for Customizing the LiveCode IDE
- ↳ Using Externals
- ↳ Making IDE Plugins
- ↳ Building Externals
- ↳ LiveCode Builder
- Platform Specific
- ↳ Windows
- ↳ Mac OS
- ↳ Linux
- ↳ iOS Deployment
- ↳ Android Deployment
- ↳ CGIs and the Server
- ↳ HTML5
- ↳ Raspberry Pi
- Academic Endeavors
- ↳ Teaching with LiveCode
- ↳ Research and Post Secondary
- ↳ LiveCode University
- ↳ Educational Outreach
- Livecode Open Source Archived Forum- closed to posting
- ↳ Engine Contributors
- ↳ IDE Contributors
- ↳ Documentation and Tutorials
- ↳ Brainstorms
- ↳ Community Projects
- ↳ rIDE
- Third Party Extension Support
- ↳ Marketing Your Products
- ↳ Animation Engine
- ↳ chartsEngine
- ↳ MobGUI
- ↳ lcTaskList
- ↳ SQL Yoga
- ↳ MergEXT
- ↳ Data Grid Helper
- ↳ idea2app and Coding School
- ↳ Admin Archive
- LiveCode Hosting
- Forum Archives
- ↳ Archived: Third Party Extension Support
- ↳ rTree
- ↳ rGrid
- ↳ Data Tree
- ↳ Archived: LiveCode Open Source
- ↳ LiveCode Global Jam
- ↳ Testing Support
- ↳ Archived: Academic Endeavors
- ↳ September Academy
- ↳ Summer School 2013
- ↳ Archived: Project Specific
- ↳ Business and Kiosks
- ↳ Digital Art and Portfolios