Hi All,
I am trying to use LWP ( i dont mind using something else ) to do some posts and get from a website API
But i am failing at the first step.
According to their docs you need to login with your broswer, get the cookie AUTH_TOKEN and get the and then use that output for the curl command authorization. Is there way to do this in perl ?
The curl would look like
and my LWP looks likecurl -X GET "<URL> -H "accept: application/json" -H "authorization:<to +ken>"
Thanks amy $cookies = HTTP::Cookies->new(); my $ua = LWP::UserAgent->new( cookie_jar => {} ); $req -> authorization_basic ( 'cloud-bespoke' ); my $rc = REST::Client->new( { useragent => $ua } ); my $headers = {Content-type => 'application/json'}; my $client = REST::Client->new( { useragent => $ua }); my $res = $client->POST('URL', '{"username": "username, "password":"password"}', {"Content-type" => ' +application/json'}); chkerr($client->responseCode()); print $client->responseContent(); print "\n" . $cookies->as_string;
In reply to LWP get Cookies for API by abs52
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |