Skip to main content
laurag81531923
Participant
Apr 18, 2019 9:07 PM UTC
Question

INVALID_MULTIPART - Error

Hi,

REST API not working for me in PHP script.

If i use "Content-Type: application/x-www-form-urlencoded", i got this error below :

{"code":"UNSUPPORTED_MEDIA_TYPE","message":"Content type was not provided or is not supported"}

If i use "Content-Type: multipart/form-data;", i got this error below :

{"code":"INVALID_MULTIPART","message":"An invalid multipart was specified"}

If I use "Content-Type: application/json", i got this :

{"code":"INVALID_JSON","message":"An invalid JSON was specified"}

I don't know what to use more. Can someone tell me if my code is good ? Many thanks !

curl_setopt_array($curl, array(

  CURLOPT_URL => "https://api.eu1.echosign.com/api/rest/v6/transientDocuments",

  CURLOPT_RETURNTRANSFER => true,

  CURLOPT_ENCODING => "",

  CURLOPT_MAXREDIRS => 10,

  CURLOPT_TIMEOUT => 0,

  CURLOPT_FOLLOWLOCATION => false,

  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,

  CURLOPT_CUSTOMREQUEST => "POST",

  CURLOPT_POSTFIELDS => array('File-Name' => 'CGA.pdf','File'=> new CURLFILE('')),

  CURLOPT_HTTPHEADER => array(

    "Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",

    "Content-Type: application/json",

  ),

));

Have a nice day !

Laura

    This topic is closed to new replies. Start a new post to keep the conversation going.

    3 replies

    Meenakshi_Negi
    Legend
    Jul 26, 2019 11:10 PM UTC

    Hi Laura,

    Did the above steps help?

    Please update the thread if the issue is resolved.

    I have checked the account with the email address used to sign in to the Forums.

    It shows that you have an Adobe Sign Developer account.

    If you need any help, please contact the Adobe Sign pre-sales team form this link Adobe Sign – Plans and pricing for enterprise and individuals | Adobe Document Cloud 

    They will help you be able to provide pre-sales technical assistance.

    Hope the information helps.

    Regards,

    Meenakshi

    Translate
    Participant
    Oct 6, 2020 6:41 PM UTC

    Content-Type header : "multipart/form-data"

    mimeType = "application/msword";

    file name : Adobe-Sign.docx 

    Will resolve above issue

    Translate
    Participant
    Jun 5, 2019 8:32 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