Jira API Issue - CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set limited options on shared hosting

Im running some code on Atlassian Jira bug system API, here is the code im using

$username = 'xxx';
$password = 'xxx';

$url = 'https://xxx.atlassian.net/rest/api/2/issues/?filter=12202';
//$url = 'https://xxx.atlassian.net/rest/api/2/issue/bug-5555';

$curl = curl_init();
curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);

$issue_list = curl_exec($curl);
$issue_json = json_decode($issue_list);
print_r($issue_json);

Thats basically all the code, now if i run that code i get a server error:

CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in /usr/local/pem/vhosts/117355/webspace/httpdocs/morny.me/jira_filters.php on line 388

However if i run the commented code instead:

$url ='https://xxx.atlassian.net/rest/api/2/issue/bug-5555';

That works fine with no issues.

To be honest i have no idea what the problem is so i sent an email to my hosting company

Hi Paul,

The safe_mode is disabled across our servers by default. Please bear in mind that the link you provided for second solution describes single site manual configuration, this is not something we would perform on the shared hosting.

When i try to access the conf folder or the .htaccess file or anything outside the httpdocs folder it says i dont have permission so looks like im limited on what i can change.

Is there any workaround?

1 answer

This widget could not be displayed.

Hi Paul,

Looking at your code, it seems to be you have't set the request method, also why do you need to include (CURLOPT_FOLLOWLOCATION) in your code?

However, I wrote a PHP code some time ago to fetch the project information, you may change the URL and try to run it, parhaps it can work:

<?php

$username = 'testclient';
$password = 'test@123';
 
$url = "https://xxxxxx.atlassian.net/rest/api/2/project";
$ch = curl_init();
 
$headers = array(
    'Accept: application/json',
    'Content-Type: application/json'
);
 
$test = "This is the content of the custom field.";
 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
//curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
 
$result = curl_exec($ch);
$ch_error = curl_error($ch);
 
if ($ch_error) {
    echo "cURL Error: $ch_error";
} else {
    echo $result;
}
 
curl_close($ch);

?>

Cheers,

Omar

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Thursday in United States

Local Atlassian Research Workshop opportunity on Sep. 28th

We're looking for participants for another workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sh...

67 views 0 0
View post

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you