How do I get a ticket id once I have created a new ticket

Mike Bates's Avatar

Mike Bates

18 Jan, 2014 12:00 AM

I'd like to display a link to the lighthouse ticket in my app once the ticket has been created.

I'm using PHP and this is my code

 $curl = curl_init();
    curl_setopt( $curl, CURLOPT_URL, $url );
    curl_setopt( $curl, CURLOPT_USERPWD, $this->lighthouse[ 'user' ] . ':' . $this->lighthouse[ 'password' ] );
    curl_setopt( $curl, CURLOPT_HTTPHEADER, array( "Content-Type: application/xml", "X-LighthouseToken: " . $this->lighthouse[ 'token' ], "Content-length: " . strlen( $xml ) ) );
    curl_setopt( $curl, CURLOPT_POST, 1 );
    curl_setopt( $curl, CURLOPT_POSTFIELDS, $xml );
    $curlData = array(
        'errno' => curl_errno ( $curl ),
        'error' => curl_error ( $curl ),
        'header' => curl_getinfo ( $curl ),
        'http_code' => curl_getinfo ( $curl, CURLINFO_HTTP_CODE )
    );
    $result = curl_exec( $curl );`

It creates the tickets successfully, do I now have to GET tickets.xml and assume that the last ticket in there is my ticket?

  1. 1 Posted by Julien on 18 Jan, 2014 01:00 AM

    Julien's Avatar

    Hi Mike,

    If the create is successful, you do get the full ticket back in the response, which is the same as doing a GET. So you would have the ticket number, URL, etc.

  2. 2 Posted by Julien on 18 Jan, 2014 01:01 AM

    Julien's Avatar

    Also, you can use JSON too. You don't have to use XML.

  3. 3 Posted by Mike Bates on 18 Jan, 2014 05:56 AM

    Mike Bates's Avatar

    Thanks Julien, I was using XML and didn't see anything in the response ($curlData and $result in my code)

    I'll switch over to JSON, I prefer that anyway as I can switch to using jquery instead of curl.

  4. 4 Posted by Julien on 18 Jan, 2014 11:18 PM

    Julien's Avatar

    Great!

    If you need additional help, just let us know.

    Cheers!

  5. Julien closed this discussion on 18 Jan, 2014 11:18 PM.

Discussions are closed to public comments.
If you need help with Lighthouse please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac