Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6847989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:48:43+00:00 2026-05-27T00:48:43+00:00

I have a question regarding to the code that OCRApiService.com provides to devs. This

  • 0

I have a question regarding to the code that OCRApiService.com provides to devs.

This is the code they provide:

//author : Altaf A. M.
//Code Snippet to convert the captured/picker'd (sic) image via OCRApiService 
//Input parameter: UIImage
//output parameter: NSString
//updates possible(rather necessary): integrate it asynchronously

- (NSString *) upload:(UIImage *)myImage
{
    NSString *urlString = @"http://api.ocrapiservice.com/1.0/rest/ocr";
    NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
    [request setURL:[NSURL URLWithString:urlString]];
    [request setHTTPMethod:@"POST"];

    NSMutableData *body = [NSMutableData data];

    NSString *boundary = [NSString stringWithString:@"---------------------------14737809831466499882746641449"];
    NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
    [request addValue:contentType forHTTPHeaderField:@"Content-Type"];

    // file
    //    NSData *imageData = UIImagePNGRepresentation(myImage);
    NSData *imageData = UIImageJPEGRepresentation(myImage, 1.0);
    [body appendData:[[NSString stringWithFormat:@"--%@", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[[NSString stringWithString:@"Content-Disposition: attachment; name=\"image\"; filename=\".jpg\""] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream"] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[NSData dataWithData:imageData]];
    [body appendData:[[NSString stringWithString:@""] dataUsingEncoding:NSUTF8StringEncoding]];

    // Text parameter1

    NSString *param1 = @"en";
    [body appendData:[[NSString stringWithFormat:@"--%@", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"language\""] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[[NSString stringWithString:param1] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[[NSString stringWithString:@""] dataUsingEncoding:NSUTF8StringEncoding]];

    // Another text parameter

    NSString *param2 = @"YOUR_API_KEY";
    [body appendData:[[NSString stringWithFormat:@"--%@", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"apikey\""] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[[NSString stringWithString:param2] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[[NSString stringWithString:@""] dataUsingEncoding:NSUTF8StringEncoding]];

    // close form

    [body appendData:[[NSString stringWithFormat:@"--%@--", boundary] dataUsingEncoding:NSUTF8StringEncoding]];

    // set request body

    [request setHTTPBody:body];

    //return and test

    NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
    NSString *returnedString = [[[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding] autorelease];


    //  NSLog(@"received string = %@", returnString);

    //  UIAlertView *returnedText = [[UIAlertView alloc] initWithTitle:@"Returned Text" message:[NSString stringWithFormat:@"%@", returnString] delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];

    //  [returnedText show ];

    //  [returnedText release];

    return returnedString;

}

I put in my API Key but the problem is whenever I call this method, I get

received string = HTTP/1.1 400 Bad Request
The language parameter is missing

According to the docs, I have set the language correctly but I am not sure why it is still coming up with this error message…

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:48:44+00:00Added an answer on May 27, 2026 at 12:48 am

    I am the owner of ocrapiservice.com.

    The api is working but there is a bug in the code snippet.
    Could you please open an issue on https://github.com/smart-mobile-software/ocrapiservice/issues ?

    We will correct it within the week.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question regarding the following code snippet I came across in one
i have a question regarding this Haskell code: module Queue (Queue, emptyQueue, queueEmpty, enqueue,
I have a question regarding this article. Between this code function odds(n, p) {
So I'm reading K&R book and I have a question regarding this code: int
I have a question regarding static function in php. let's assume that I have
I have a question regarding string modification. Let's assume that we have the following
Hey, I have a question regarding code structure, and was wondering what the best
I have a question regarding restricted pointer assignments. See the comments in code for
I have general question regarding the use of pointers vs. references in this particular
I have a question regarding the std::sort algorithm. Here is my test code: struct

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.