1

I have been working on some code to automate an update to a specific task in AtTask using the API. I am finding some problems using PHP's CURL request for a PUT command. Here is a copy of the code:

    $updateURL = "https://[COMPANYURL].attask-ondemand.com/attask/api/v4.0/task?updates={'ID':'TASKID','name':'Ok. Here we go again','commitDate':'2015-10-27T17:30'}";
    $curl = curl_init();

    curl_setopt_array($curl, array(
        CURLOPT_URL => $updateURL,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => "",
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 30,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => "PUT",
        CURLOPT_HTTPHEADER => array(
            "sessionid: " . $this->sessionId
        ),
    ));

    $attask_update_json = curl_exec($curl);

The code executes with out any errors being reported, but the return response is blank. I have verified my URL using postman and it processes correctly, but I can not get the code to process in PHP. Any help would be appreciated.

Yeldar Kurmangaliyev
  • 33,467
  • 12
  • 59
  • 101
Ben D. S.
  • 35
  • 6
  • Try to use curl_getinfo to get the details of the response ... after your curl_exec part $info = curl_getinfo($curl ); also some times postman plugin gives different output :( – AnNaMaLaI Sep 29 '15 at 03:59
  • Thanks for the quick response. It looks I was getting a 505 HTTP response code using the getinfo request. I will have to see if I can figure out how to get around the 505 error. I wish I could figure out what code sample postman used, but for some reason the PUT commands in postman does not allow me to preview what code they used to submit the curl request. This way I could see what HTTP version they used in their CURL request. – Ben D. S. Sep 29 '15 at 04:38
  • 505 HTTP Version Not Supported The server does not support the HTTP protocol version used in the request. – AnNaMaLaI Sep 29 '15 at 04:39
  • That is what I was looking at also. It looks like I was using CURL_HTTP_VERSION_1_1. So I guess I need to find out what version AtTask API services support. I have not been able to find that yet. I will have to keep looking. – Ben D. S. Sep 29 '15 at 04:42
  • you can try in 2 ways from your end with out contacting AtTask . first : http://stackoverflow.com/a/23347155/744478 second : http_build_query(). – AnNaMaLaI Sep 29 '15 at 04:46

0 Answers0