This topic contains 1 reply, has 2 voices, and was last updated by  Duo_Liang 9 months, 2 weeks ago.

  • Author
  • Participant
    Senior Member
    Member since: 16.07.2018
    Number of posts: 118

    Is it possible to send multiple documents via one API call and one transaction?

    This is similar to the code in the example, can I just append each file to a new form for the MultipartFormDataContent?

    ByteArrayContent content = new ByteArrayContent(fileByteArray);
    content.Headers.ContentDisposition = new ContentDispositionHeaderValue(“form-data”);
    content.Headers.ContentDisposition.Name = “\”file\””;
    content.Headers.ContentDisposition.FileName = “\”” + MiscFunctions.RemoveSpecialCharacters(pdfDoc.Name) + “.pdf” + “\””;
    content.Headers.ContentType = new MediaTypeHeaderValue(“application/pdf”);

    MultipartFormDataContent form = new MultipartFormDataContent();
    form.Add(content, $”\”file\””, “\”” + MiscFunctions.RemoveSpecialCharacters(pdfDoc.Name) + “.pdf” + “\””);
    form.Add(jsonContent, “\”payload\””);

    Member since: 14.06.2018
    Number of posts: 828



    Hi Ryan,

    To explain the actual format of http request more clearly, the first attachment is a snippet excerpted from Fiddler. From the screenshot, you can see each Content-Disposition is actually separately by "--"+boundary. If you need to upload multiple documents, the name of the Content-Disposition shares the same as “file”.
    And at the end, you need to use "--"+boundary+"--" to end the request.

    And the second attachment is an example for creating a package with multiple documents, but it’s using WebClient object to send the same REST package.

    Hope this could help you!


    Duo Liang
    OneSpan Junior Technical Evangelist
    You must be logged in to view attached files.

You must be logged in to reply to this topic.