How to create a cURL POST request in PHP
The Problem could be in the way you have formatted the values in the $postData
array.All values including the JSON text should be in single quotes.Look at how I did it though the response was an error which I believe is a valid error
$postData = array( "title" => "Test task", "description" => "Test task description", "status" => "Active", "importance" => "Normal", "dates" => '{"start":"2016-05-18","due":"2016-05-25"}', "shareds" => '["KUAHYFH4"]', "parents" => '["IEAE34A4I4ATKP4L"]', "responsibles" => '["KUAHYFH4"]', "followers" => '["KUAHYFH4"]', "follow" => "true", "priorityBefore" => "IEAE34A4KQATKP4S", "priorityAfter" => "IEAE34A4KQATKP4S", "superTasks" => '["IEAE34A4KQATKP4S"]', "metadata" => '[{"key":"testMetaKey","value":"testMetaValue"}]', "customFields" => '[{"id":"IEAE34A4JUAADKT3","value":"testValue"}]', "customStatus" => "string" );$handler = curl_init();$access_token = "<access_token>";$headers[] = 'Authorization: bearer '.$access_token;curl_setopt($handler, CURLOPT_URL, "https://www.wrike.com/api/v3/folders/IEAE34A4I4ATKP4L/tasks");curl_setopt($handler, CURLOPT_POSTFIELDS, http_build_query($postData));curl_setopt($handler, CURLOPT_HTTPHEADER,$headers);curl_setopt($handler, CURLOPT_POST, true);curl_setopt($handler, CURLOPT_SSL_VERIFYPEER, false);$response = curl_exec($handler);if($response !==false){ var_dump($response);}else { print "Could not get a response";}
The response was
{"errorDescription":"Access token is unknown or invalid","error":"not_authorized"}