Eroln has asked for the wisdom of the Perl Monks concerning the following question:
I should add that code is fully functional when running with basic authentication. The main change is in "new" method. Here I add a line with cookie jar & removed basic authentications.
Cookie to the code is supplied in the form of text: JSESSIONID=F97AC6F5AD33D54D0C06F4CBF0230C43 in JSON cookie jar is visible:sub new_c { my ($class, $url, $cookie) = @_; my $self = { url => $url, auth_url => $auth_url }; bless $self, $class; $self->{_ua} = LWP::UserAgent->new(); $self->{_ua}->cookie_jar({cookies => $cookie} ); return $self; }
Then I post GET request and answer is 401 error.$VAR1 = bless( { '_ua' => bless( { 'cookie_jar' => 'JSESSIONID=F97AC6F +5AD33D54D0C06F4CBF0230C43', }, 'LWP::UserAgent' ), }
I suspect I messed correct cookie jar writing, but out of ideas how to write it.garbage after JSON object, at character offset 4 (before "Can't locate + object .. .") at C:/strawberry/perl/site/lib//JIRA/Client/Automated.pm line 385. request GET /rest/api/latest/issue/JIML-3044: at main.pl line 30 response 401 Unauthorized: {"errorMessages":["You do not have the perm +ission to see the specified issue.","Login Required"],"errors":{}} at main.pl li +ne 30 Unable to GET /rest/api/latest/issue/JIML-3044: 401 Unauthorized{ errorMessages => [ "You do not have the permission to see the specified issue.", "Login Required", ], errors => {}, }
Note, I have access rights for the issue, the cookie itself is functional - both checked using curl. Any idea to supply cookie to cookie_jar to be usable?
There is very similar question in monastery: http://www.perlmonks.org/?node_id=456612, but it was not answered in a way I can use.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: what is the correct way to set cookie in LWP::UserAgent
by Corion (Patriarch) on Jun 14, 2017 at 09:38 UTC | |
by Eroln (Novice) on Jun 15, 2017 at 02:43 UTC | |
by huck (Prior) on Jun 15, 2017 at 03:26 UTC | |
by Eroln (Novice) on Jun 19, 2017 at 04:21 UTC | |
|
Re: what is the correct way to set cookie in LWP::UserAgent
by Eroln (Novice) on Jun 21, 2017 at 01:28 UTC |