Not signed in (Sign In)
The Intervals Forum is read-only
Please head to for help articles and guides. If you have any questions, please contact our support team.


API PHP Code Sample: Create a Task

Bottom of Page


    In this PHP code sample we'll see how to create a task from XML data using the API and the Curl library. When using this code, remember to replace variable values with your own to avoid errors.

    The API documentation for the task resource can be found at:

    //create the xml file to POST
    $putString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
    $putString .= "<task>\n";
    $putString .= "<statusid>67329</statusid>\n";
    $putString .= "<projectid>920391</projectid>\n";
    $putString .= "<moduleid>667821</moduleid>\n";
    $putString .= "<title>New Task</title>\n";
    $putString .= "<dateopen>2010-05-26</dateopen>\n";
    $putString .= "<datedue>2010-05-29</datedue>\n";
    $putString .= "<priorityid>46781</priorityid>\n";
    $putString .= "<ownerid>97351</ownerid>\n";
    $putString .= "<assigneeid>101881, 100283</assigneeid>\n";
    $putString .= "<summary>A summary of the task</summary>\n";
    $putString .= "</task>\n";

    //set api token value to your api token
    $apiToken = "";

    //intialize and send the curl request
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_USERPWD, $apiToken. ":");
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/xml", "Content-type: application/xml"));
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $putString);
    $response = curl_exec($ch);

    //output the resulting XML
    echo $response;

Comments are closed.
For more Intervals help documentation, please visit