This topic contains 1 reply, has 2 voices, and was last updated by  Duo_Liang 1 week, 4 days ago.

  • Author
    Posts
  • Participant
    Ryan_Coleman
    Member
    Member since: 16.07.2018
    Number of posts: 21

    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\””);

    Keymaster
    Duo_Liang
    Guru
    Member since: 14.06.2018
    Number of posts: 183

    Score

    0

    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


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

You must be logged in to reply to this topic.