Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

500 when use API to initiate a pipeline using PHP

Sihan Zhang May 28, 2019

Hi, 

I want to initiate a pipeline in a customized function on my website. However, I only got 500 response. Is there anything wrong with my code?

Here is the php code:

$ch = curl_init("https://api.bitbucket.org/2.0/repositories/my-workspace/my-repo/pipelines/");

$userpwd = "username:password";
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, $userpwd);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json'
));
$vars = json_decode(array(
"target" => array(
"ref_type" => "branch",
"type" => "pipeline_ref_target",
"ref_name" => "develop"
)
));
curl_setopt($ch, CURLOPT_POSTFIELDS,$vars);

curl_exec($ch);
curl_close($ch);

 

Here is my response data:

{
"code": 500,
"message": "There was an error processing your request. It has been logged (ID fd114d958c0e63e1)."
}

 

I can feel that I need to check the log to view error detail. I tried Bitbucket Server, but can not access to my current repo. Can anybody point out what I'm missing here? I'm new to Bitbucket product. Please forgive me if I made some silly mistakes. 

Thanks a lot!

1 answer

1 accepted

0 votes
Answer accepted
Sihan Zhang May 29, 2019

Solved. I made a silly mistake myself

jredmond
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 29, 2019

Could you please elaborate so that the next person having this problem knows what to do?

Sihan Zhang June 3, 2019

Sure. I should have used json_encode instead of json_decode

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events