Code:
use REST::Client; use JSON qw//; use MIME::Base64; use Data::Dumper; use LWP::UserAgent; use JIRA::Client; `export PERL_LWP_SSL_VERIFY_HOSTNAME=0`; my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 }, protocols_allowed => ['https'], ); my $username = 'saravanan.subramanian@cmegroup.com'; my $password = 'AXXX'; my $base_url = 'https://cmegroup-sandbox-461.atlassian.net'; #my $jira_rest = JIRA::Client::Automated->new('https://cmegroup-sandbox-461.atlassian.net', $user, $passwd); my $jira_rest = REST::Client->new(); $jira_rest->addHeader('Content-Type','application/json'); $jira_rest->addHeader('Authorization','Basic'.encode_base64("$username:$password")); $jira_rest->GET('https://cmegroup-sandbox-461.atlassian.net/rest/api/3/search?jql=project=vmt'); print Dumper($jira_rest); print $jira_rest->responseCode();
'
I get 400 error when i am rying to run the code below. How ever the I have access to project
when i removed the single quotes in the link below I am able to see the results returned in the UI. Please let me know how to fix it
Error:
_rc' => '400', '_content' => '{"errorMessages":["The value \'vmt\' does not exist for the field \'project\'."],"warningMessages":[]}', '_msg' => 'Bad Request', '_protocol' => 'HTTP/1.1', '_request' => bless( { '_uri' => bless( do{\(my $o = 'https://cmegroup-sandbox-461.atlassian.net/rest/api/3/search?jql=project=vmt')}, 'URI::https' ), '_headers' => bless( {
URL
https://cmegroup-sandbox-461.atlassian.net/rest/api/3/search?jql=project=vmt'
Your Authorization header is missing a space after 'Basic', and the encode_base64
function adds a newline character by default, which can corrupt the header. Have you tried adding a space as below?
$jira_rest->addHeader('Authorization', 'Basic '.encode_base64("$username:$password", ''));
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
silly me - it worked . Thank you very much
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
:) glad it worked
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.