API invalid multipart
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
In postman, you have to choose file type for the file you upload
Copy link to clipboard
Copied
How do you choose the file type? I'm not sure what you mean by this.
Copy link to clipboard
Copied
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 ' .
Copy link to clipboard
Copied
````
$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.

