Skip to main content
true14361727
Participant
Apr 16, 2018 7:19 PM UTC
Question

API invalid multipart

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 is closed to new replies. Start a new post to keep the conversation going.

    4 replies

    Participant
    Jun 5, 2019 8:29 PM UTC

    ````

    $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.

    Translate
    Participant
    Jul 17, 2018 1:28 PM UTC

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

    Translate
    Mar 14, 2019 3:58 PM UTC

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

    Translate
    Legend
    Apr 11, 2019 8:55 AM UTC

    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 ' .

    Translate