update customField curl php

Fröhlich László
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 27, 2022

Hi all,

I'm stucked very well. Every GET request works fine, but I can't set any customFiled value with php curl. 

My first problem, that I cant achive any answer from the server, so I absolutely dont know where do I something wrong. (All my GET requests works fine)

My code: 

$data = array(
   'idValue' => $cflistdvalueid,
   'key' => $userDetails->t_key,
   'token' => $userDetails->t_token
);

$headers = array(
   "Content-Type: application/json",
);

$domain = "https://api.trello.com";
$request = "/1/card/".$cid."/customField/".$cfid."/item";
//variables checked with GET request, id-s are OK.

Function: 

$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_URL, $domain.$request);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

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

Called full link: 
https://api.trello.com/1/card/62a832b4f852XXXXX1341f99/customField/62bbf364f1d04c8XXXXXX5a8/item

I'v got nothing back from the server, return is empty. Nor an error message, returns NULL... :(

Can you please help me, what I'm doing wrong? 

 

1 answer

1 accepted

2 votes
Answer accepted
Fröhlich László
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 27, 2022

Solved!

(But still no answer from the server.....)

I changed $data like this: 
$data = '{"idValue": "'.$cflistdvalueid.'","key": "'.$userDetails->t_key.'","token": "'.$userDetails->t_token.'"}';

And in the function i deleted http_build_query, so the CURLOP_POSTFILEDS line looks like this:

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

It works. Even I got nothing from the server back.

Thanks.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events