Skip to main content
true14361727
Participant
April 16, 2018
Question

API invalid multipart

  • April 16, 2018
  • 2 replies
  • 2845 views

Using both PHP Curl and Postman, i am attempting to use API v5 to create a transient document that can then be used for an agreement.  However, no matter what settings i use in the HTTP header for "Content-Type" and "Content-Disposition", beginning with the example "multipart/form-data" and "form-data; name='File"; filename:"C:\DRAFT.pdf, I only get this for the response:

code: INVALID_MULTIPART

message: An invalid multipart was specified.

    This topic has been closed for replies.

    2 replies

    Participant
    June 5, 2019

    ````

    $handle = curl_init();

    $file = __DIR__ . DIRECTORY_SEPARATOR . "helloWorld.docx";

    $header = array();

    $header[] = 'Content-Type: multipart/form-data';

    $header[] = 'Authorization: Bearer ' . $this->refreshToken;

    $header[] = 'Content-Disposition: form-data; name=";File"; filename="helloworld.DOCX"';

    // Send the raw file in the body with no other data

    $fp = fopen($file, 'r');

    $contents = fread($fp, filesize($file));

    $postData = array(

       "File" => $contents,

       "File-Name" => 'helloWorld.docx',

         "Mime-Type" => 'application/msword'

    );

    curl_setopt_array($handle,

      array(

       CURLOPT_URL => $this->uploadDocumentUrl,

       CURLOPT_POST => true,

       CURLOPT_POSTFIELDS => $postData,

       CURLOPT_RETURNTRANSFER => true,

       CURLOPT_HTTPHEADER => $header

       )

    );

    $data = curl_exec($handle);

    curl_close($handle);

    fclose($fp);

    ````

    it should work.

    Participant
    July 17, 2018

    In postman, you have to choose file type for the file you upload

    March 14, 2019

    How do you choose the file type? I'm not sure what you mean by this.

    Legend
    April 11, 2019

    See Postman screenshots

          

    When you move the mouse over the Key field in the second screenshot you get a dropdown at the end of this field to specify if it's a file or text you want to add.

    For Api v6 it's mostly the same just change the access-token header to 'Authorization' and prefix your access token with the word 'Bearer ' .