Skip to main content
Participant
August 3, 2018
Answered

INVALID_MULTIPART ERROR

  • August 3, 2018
  • 2 replies
  • 3600 views

REST API not working for me in perl script. the following error i received.

'_content' => '{"code":"INVALID_MULTIPART","message":"An invalid multipart was specified"}',

Any one please give your feed back. what is wrong in coding


CODE

    my $ua = LWP::UserAgent->new;
    my $req = HTTP::Request->new('POST' => 'https://api.in1.echosign.com/api/rest/v5/transientDocuments');
    $req->header('Content-Type' => 'multipart/form-data');   
    $req->header('Access-Token' => '3AAABLblqZhCnnWCeJmvEvKv3qZuL3cqG4nAVg6IYwm1S4PdNkSVpaLL0E0jd629IDkbAkIg7d4zdFQPevGy2Iagt97RVYgiR');   
    $req->header('Mime-Type' => 'application/pdf');   
    $req->content($file);
    my $resp = $ua->request($req);
    print Dumper($resp);exit;

REQUEST and RESPONSE

$VAR1 = bless( {

  '_content' => '{"code":"INVALID_MULTIPART","message":"An invalid multipart was specified"}',

  '_rc' => '400',

  '_headers' => bless( {

  'x-request-id' => '53c86b11-9534-474b-9af8-3077e32312f3',

  'client-ssl-cert-issuer' => '/C=US/O=DigiCert Inc/CN=DigiCert SHA2 Secure Server CA',

  'client-ssl-socket-class' => 'IO::Socket::SSL',

  'connection' => 'close',

  'pragma' => 'no-cache',

  'client-response-num' => 1,

  'x-content-type-options' => 'nosniff',

  'p3p' => 'CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"',

  'cache-control' => 'no-cache, no-store, must-revalidate',

  '::std_case' => {

  'x-xss-protection' => 'X-XSS-Protection',

  'client-peer' => 'Client-Peer',

  'client-date' => 'Client-Date',

  'x-request-id' => 'X-Request-Id',

  'client-ssl-cert-issuer' => 'Client-SSL-Cert-Issuer',

  'client-ssl-socket-class' => 'Client-SSL-Socket-Class',

  'x-robots-tag' => 'X-Robots-Tag',

  'p3p' => 'P3P',

  'client-response-num' => 'Client-Response-Num',

  'x-content-type-options' => 'X-Content-Type-Options',

  'client-ssl-cipher' => 'Client-SSL-Cipher',

  'strict-transport-security' => 'Strict-Transport-Security',

  'client-ssl-cert-subject' => 'Client-SSL-Cert-Subject'

  },

  'client-ssl-cipher' => 'ECDHE-RSA-AES128-SHA256',

  'strict-transport-security' => 'max-age=31536000;',

  'content-type' => 'application/json;charset=UTF-8',

  'date' => 'Fri, 03 Aug 2018 05:48:34 GMT',

  'client-date' => 'Fri, 03 Aug 2018 05:48:34 GMT',

  'content-length' => '75',

  'client-peer' => '13.126.23.3:443',

  'x-xss-protection' => '1; mode=block',

  'x-robots-tag' => 'none',

  'expires' => '0',

  'client-ssl-cert-subject' => '/C=US/ST=California/L=San Jose/O=Adobe Systems Incorporated/CN=secure.echosign.com',

  'server' => 'Apache'

  }, 'HTTP::Headers' ),

  '_msg' => 'Bad Request',

  '_request' => bless( {

  '_headers' => bless( {

  'user-agent' => 'libwww-perl/6.05',

  'mime-type' => 'application/pdf',

  'content-type' => 'multipart/form-data',

  'access-token' => '3AAABLblqZhCnnWCeJmvEvKv3qZuL3cqG4nAVg6IYwm1S4PdNkSVpaLL0E0jd629IDkbAkIg7d4zdFQPevGy2Iagt97RVYgiR',

  '::std_case' => {

  'if-ssl-cert-subject' => 'If-SSL-Cert-Subject',

  'mime-type' => 'Mime-Type',

  'access-token' => 'Access-Token'

  }

  }, 'HTTP::Headers' ),

  '_content' => bless( \*{'Fh::fh00001new.pdf'}, 'Fh' ),

  '_uri' => bless( do{\(my $o = 'https://api.in1.echosign.com/api/rest/v5/transientDocuments')}, 'URI::https' ),

  '_method' => 'POST',

  '_uri_canonical' => $VAR1->{'_request'}{'_uri'}

  }, 'HTTP::Request' ),

  '_protocol' => 'HTTP/1.1'

  }, 'HTTP::Response' );

    my $ua = LWP::UserAgent->new;
    my $req = HTTP::Request->new('POST' => 'https://api.in1.echosign.com/api/rest/v5/transientDocuments');
    $req->header('Content-Type' => 'multipart/form-data');   
    $req->header('Access-Token' => '3AAABLblqZhCnnWCeJmvEvKv3qZuL3cqG4nAVg6IYwm1S4PdNkSVpaLL0E0jd629IDkbAkIg7d4zdFQPevGy2Iagt97RVYgiR');   
    $req->header('Mime-Type' => 'application/pdf');   
    $req->content($file);
    my $resp = $ua->request($req);
    print Dumper($resp);exit;

This topic has been closed for replies.
Correct answer romainl745608

Hi kotteeswaranv98206984,

Your mutlipart is invalid, in my code, i didn't define mulitpart (yes i don't follow the documentation, but this documentation is incomplete), you can test replace :

$req->header('Content-Type' => 'multipart/form-data');   

by

$req->header('Content-Type' => 'application/json');   

Regards,

Romain.

2 replies

romainl745608
romainl745608Correct answer
Participating Frequently
November 2, 2018

Hi kotteeswaranv98206984,

Your mutlipart is invalid, in my code, i didn't define mulitpart (yes i don't follow the documentation, but this documentation is incomplete), you can test replace :

$req->header('Content-Type' => 'multipart/form-data');   

by

$req->header('Content-Type' => 'application/json');   

Regards,

Romain.

Participant
November 2, 2018

Hello,  I have the same error, please help me, You found it?

Participant
November 2, 2018

You found it, the error I have the same error, please help me

romainl745608
Participating Frequently
November 5, 2018

Hello Albertog,

I don't understand your last answer, your problem is solved ?

Regards,

Romain.