Converting Command line curl to PHP curl functions Converting Command line curl to PHP curl functions curl curl

Converting Command line curl to PHP curl functions


I got solution of my problem i was missing swimlaneId attribute. I am posting code here for future reference so it will help others.

Now sending data using object like following

$object = new stdClass();   $object->name = 'Testing Task';   $object->columnId = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx';   $object->swimlaneId = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx';   $object->color = 'green';$url = "https://kanbanflow.com/api/v1/tasks";$curl = curl_init();curl_setopt($curl, CURLOPT_URL, $url);curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);curl_setopt($curl, CURLOPT_POST, true);curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($object));$response = curl_exec($curl); 

Array of Json_encode is also working here

$data = json_encode(array('name'=>'Testing of api', 'columnId' =>"f648831061e111e3a41aa3dbd7a40406", 'color'=>'red', 'swimlaneId' => 'd0635fc061e711e3a41aa3dbd7a40406'));


Looks like you forgot to json encode your data

$data = json_encode(array('name'=>'Testing of api', 'columnId' =>"xxxxxxxxxxxxxxxxxxx",'color'=>"red"));