api - Posting data as multipart/form via perl -


i perl newbie , doing rest api calls via perl. send api requests , examine via online http request inspector requestbin

i did googling , able perform successful posts if content type 'application/json'

here code

use rest::client; use mime::base64;  $email_id = 'someemail@email.com'; $email_pass = 'password'; $client = rest::client->new();  $client->sethost("http://requestb.in"); $client->addheader('content-type', 'application/json'); $client->addheader('charset', 'utf-8'); $client->addheader("authorization", "basic ".encode_base64("$email_id:$email_pass"));   $req=" {   \"new_post\":{       \"description\":\"some details on issue ...\",       \"subject\":\"custom email\",       \"email\":\"someone\@mailinator.com\",    }  }";   $response = $client->post("/pq0x1rpq",$req); print $client->responsecode(); $result = $client->responsecontent(); print $result; 

the above shown code block works fine, when try post multipart/form-data, not able post it, getting errors while execute script.

use rest::client; use mime::base64;

my $email_id = 'someemail@email.com'; $email_pass = 'password'; $client = rest::client->new();  $client->sethost("http://requestb.in"); $client->addheader('content-type', 'multipart/form-data');#please note $client->addheader('charset', 'utf-8'); $client->addheader("authorization", "basic ".encode_base64("$email_id:$email_pass"));   $req='helpdesk_ticket[subject]: subject helpdesk_ticket[description]: sample ticket helpdesk_ticket[email]: example\@example.com';   $response = $client->post("/pq0x1rpq",$req); print $client->responsecode(); $result = $client->responsecontent(); print $result; 

i think syntax multipart/form-data wrong, why getting error.

please tell me how add multipart/formdata perl.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -