I'm trying to call this API from my C# app: https://ocr.space/OCRAPI
When I call it from curl, it just works fine:
curl -k --form "file=@filename.jpg" --form "apikey=helloworld" --form "language=eng" https://api.ocr.space/Parse/Image
I implemented it this way:
 [TestMethod]
    public async Task  Test_Curl_Call()
    {
        var client = new HttpClient();
        String cur_dir = Directory.GetCurrentDirectory();
        // Create the HttpContent for the form to be posted.
        var requestContent = new FormUrlEncodedContent(new[] {
              new KeyValuePair<string, string>(  "file", "@filename.jpg"), //I also tried "filename.jpg"
               new KeyValuePair<string, string>(     "apikey", "helloworld" ),
        new KeyValuePair<string, string>( "language", "eng")});
        // Get the response.
        HttpResponseMessage response = await client.PostAsync(
           "https://api.ocr.space/Parse/Image",
            requestContent);
        // Get the response content.
        HttpContent responseContent = response.Content;
        // Get the stream of the content.
        using (var reader = new StreamReader(await responseContent.ReadAsStreamAsync()))
        {
            // Write the output.
            String result = await reader.ReadToEndAsync();
            Console.WriteLine(result);
        }
    }
I get this answer :
{
    "ParsedResults":null,
    "OCRExitCode":99,
    "IsErroredOnProcessing":true,
    "ErrorMessage":"No file uploaded or URL provided",
    "ErrorDetails":"",
    "ProcessingTimeInMilliseconds":"0"
}
Any clue?
What's the @ character for in "file=@filename.jpg"?
I put my filename.jpg file in the project and test project bin/debug directory and run my test project in debug mode.
So I don't think the error points to the file not being where expected. I'd rather suspect a syntax error in my code.
 
     
    