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

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Hipchat

Moving from Hipchat to Stride? Here’s what you’ll love

Heya, Hipchat friends! We’re so happy you’re checking out   Stride. Whether you know it or not, you have been instrumental in making Stride come to life. Every feature, design, and functionality...

77 views 2 6
Read article

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