Error from FileService Answered

I'm trying to upload a document as per the specifications in the developer help file in

Application Programming Interface (API) > Using the Web Services API of the ABBYY FlexiCapture Application Server > Scanning Documents

I'm stuck on step 6 of the 8 steps ("Add pages/documents into the batch"). I'm trying to use a POST request to add the document image, as per the documentation. When I submit the post request, I get (500) Internal Server Error, and the description is "Method parseParameters failed". See below for sample code - broken into a few comments due to limits on comment size.

Was this article helpful?

0 out of 0 found this helpful



  • Avatar
    Yehuda Goldenberg

            public static string POSTSaveFile(string AppServerURL, int sessionId, int projectId, 

                int batchId, int objectType, int objectId, int version, string streamName, string content)


                int requestId = Environment.TickCount;




                    // form the request

                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create($"{AppServerURL}/FileService/v1");

                    request.Method = "POST";


                    // working with authentication, specified when connecting to the web-service

                    if (basicAuthenticationCredentialCache != null)


                        basicAuthenticationCredentialCache.Add(request.RequestUri, "Basic", new NetworkCredential(userName, password));

                        request.Credentials = basicAuthenticationCredentialCache;




                        request.UseDefaultCredentials = true;



                    request.ContentType = "multipart/form-data, boundary=" + requestId;

                    byte[] streamNameInBytes = Encoding.Unicode.GetBytes(streamName);


  • Avatar
    Yehuda Goldenberg

                    UnicodeEncoding UTFencofing = new UnicodeEncoding();

                    const string format = "\r\n--{0}\r\ncontent-disposition: form-data;name=\"{1}\"\r\n\r\n{2}";

                    var sb = new StringBuilder();

                    sb.AppendFormat(format, requestId, "Action", "Save");

                    sb.AppendFormat(format, requestId, nameof(objectType), objectType);

                    sb.AppendFormat(format, requestId, nameof(sessionId), sessionId);

                    sb.AppendFormat(format, requestId, nameof(projectId), projectId);

                    sb.AppendFormat(format, requestId, nameof(batchId), batchId);

                    sb.AppendFormat(format, requestId, nameof(objectId), objectId);

                    sb.AppendFormat(format, requestId, nameof(version), version);

                    sb.AppendFormat(format, requestId, "streamName", Convert.ToBase64String(streamNameInBytes));

                    sb.AppendFormat(format, requestId, $"blob\";filename=\"{fileName}\"\r\nContent-Type: application/octet-stream\r\nContent-Transfer-Encoding: binary", string.Empty);


                    sb.AppendFormat("\r\n--{0}--\r\n", requestId);


                    using (var writer = new StreamWriter(request.GetRequestStream(), Encoding.Default))





                    // get the response and analyse it

                    using (var response = (HttpWebResponse)request.GetResponse())

  • Avatar
    Yehuda Goldenberg

                    using (var responseStream = response.GetResponseStream())

                    using (var reader = new StreamReader(responseStream))


                        return reader.ReadToEnd();



                catch(WebException wex)



                    Console.WriteLine("----------- Data --------------");

                    using (var responseStream = wex.Response.GetResponseStream())

                    using (var reader = new StreamReader(responseStream))





                    return null;




  • Avatar
    Alexey Efremov


    I am sorry for not tryong your code for now, but could you please check this project and let me know if this works for you:


  • Avatar
    Yehuda Goldenberg

    Thank you - this project was helpful.

    I updated the code to use HttpClient instead of HttpWebRequest. With HttpClient the code is more concise and it looks like I got further along in the process, but it still doesn't save the file.

    The error I get now is:

    (500) Internal program error:
    Src\FileSystemStorage.cpp, 244.
     in method CFileServiceHandler::HandleRequest (Save)

     Here's the updated code:

            public static string POSTSaveFile(string AppServerURL, int sessionId, int projectId,
                int batchId, int objectId, string streamName, byte[] content)
                HttpContent bytesContent = new ByteArrayContent(content);
                bytesContent.Headers.Add("Content-Type", "application/octet-stream");
                bytesContent.Headers.Add("Content-Transfer-Encoding", "binary");


                byte[] streamNameInBytes = Encoding.Unicode.GetBytes(streamName);
                var authArray = Encoding.UTF8.GetBytes($"{userName}:{password}");


                using (var client = new HttpClient())
                using (var formData = new MultipartFormDataContent())
                    client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(authArray));
                    formData.Add(new StringContent("Save"), "Action");
                    formData.Add(new StringContent("0"), "objectType");
                    formData.Add(new StringContent(sessionId.ToString()), nameof(sessionId));
                    formData.Add(new StringContent(projectId.ToString()), nameof(projectId));
                    formData.Add(new StringContent(batchId.ToString()), nameof(batchId));
                    formData.Add(new StringContent("0"), "parentId");
                    formData.Add(new StringContent(objectId.ToString()), nameof(objectId));
                    formData.Add(new StringContent("0"), "version");
                    formData.Add(new StringContent(Convert.ToBase64String(streamNameInBytes)), nameof(streamName));
                    formData.Add(bytesContent, "blob", fileName);


                    var response = client.PostAsync($"{AppServerURL}/FileService/v1", formData).Result;


                    return response.Content.ReadAsStringAsync().Result;

  • Avatar
    Alexey Efremov

    Hello, according to our database, this error message appears only when you open 2 sessions and then change project/task for one or both of them.

    Please also check your filestorage for files with names starting with "7-0-" and try to remove them. (Please do a backup beforehand)

    Please try to change the name of the file you are uploading.


    Similar issue was already fixed by our engineers in the build and later. Please update to the latest version of FC12.

    If however, you are using the latest version and the issue persists, please contact your regional support. 

    Here is the information they may request to resolve the issue:

    1. An exact version of your FC12: Project Setup Station > Help > About.

    2.  Ainfo diagnostic files from all the FlexiCapture machines:

     - Run AINFO.exe file from the program installation folder: ABBYY FlexiCapture 12.0 Servers\Support or  ABBYY FlexiCapture 12.0 Stations\Support;

     - Click "Save as";

     - Send us

    4. Windows Application and System logs:

    - Go to Control Panel > Administrative Tools > Event Viewer.

    - From the log tree, select the "Application"/"System" item.

    - From the "Action" menu, select the "Save log file as..." item.

    - Save the *.evtx file, zip and send it to us.

    5. Your VS project



  • Avatar
    Yehuda Goldenberg

    I currently have version 12.0.475, which is the latest version on Is there a way to get a newer version?

    I only have one project uploaded to my server, so I don't see how I could have changed the project.

    There are no files in my filestorage that have a name starting with 7-0-.

    I tried closing any open sessions and opening a new session and I still got the same error.

    This is also a day later so any open sessions from yesterday timed out. Also I checked in the processing monitor and the only open sessions are my current session and one "Processing Server" session.

    I also tried renaming the file that I was attempting to upload, and I also tried specifying a different filename for the upload.

    I still got the same error.

  • Avatar
    Yehuda Goldenberg

    I got this working using a different application I wrote in PHP. I'm not sure why the .Net version still isn't working, but I will revisit that later. Here's the PHP code that works.

    private function postMultiPart($file, $objectId, $sessionId, $projectId, $batchId)
    $ch = curl_init($this->url.FlexiCaptureApiClient::POSTENDPOINT);
    curl_setopt_array($ch, [
    CURLOPT_POST => true,
    'AUTHORIZATION: '.$this->authHeader,
    'Content-Type: multipart/form-data'
    'Action' => 'Save',
    'objectType' => 0,
    'sessionId' => $sessionId,
    'projectId' => $projectId,
    'batchId' => $batchId,
    'parentId' => 0,
    'objectId' => $objectId,
    'version' => 0,
    'streamName' => base64_encode(basename($file)),
    'blob' => new \CURLFile($file, 'application/octet-stream', basename($file))

    $result = curl_exec($ch);
    $errno = curl_errno($ch);
    $error = curl_error($ch);
    return [
    'result' => $result,
    'errno' => $errno,
    'error' => $error
  • Avatar
    Yehuda Goldenberg

    I'm continuing this discussion in a new post: see

    This is the next step in the process that I'm stuck on.

  • Avatar
    Alexey Efremov

    Since the workaround I have proposed does not work for you, please contact your regional support and provide the information i described above.

    The format of this forum does not allow the proper discussion on the issue.



Please sign in to leave a comment.