Using the API with PHP
It seems that we can no longer create tickets through the API. From what I can tell, it looks like the POST to the API is just returning "1". Nothing has changed on our end, but maybe there was a recent change to the API or it's somehow down at the moment?
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
Support Staff 1 Posted by Tiger Team on 25 Apr, 2013 08:15 PM
The only thing that's different is that we recently changed load balancers (SSL and IP address changed) but the old setup is still running and should work. Are you using a library to access the API? Can you reproduce with, say, just cURL?
2 Posted by gazugafan on 25 Apr, 2013 08:32 PM
We're using curl via PHP. The code is basically the same as found here...
http://help.lighthouseapp.com/discussions/api-developers/39-api-php...
I haven't tried using just curl via command line yet... I've never tried that, actually, so trying to craft a curl command that replicates what we're doing in php might take a bit for me to wrap my head around. Before I get into that, could you take a quick look at the php example code and see if there's anything obvious to you that could cause this?
3 Posted by Colin Gray on 25 Apr, 2013 09:29 PM
We're seeing the same problem using the same sample code from:
http://help.lighthouseapp.com/discussions/api-developers/39-api-php...
This has worked fine for us for months, but is now returning an empty result and not creating the ticket.
Using curl from the command line, I have been able to create a ticket, so it's not apparent to me what has changed.
Any advice?
Support Staff 4 Posted by Tiger Team on 25 Apr, 2013 10:37 PM
If it suddenly broke, it's likely our fault..! I will take a look. Are you including any yaml in your XML?
Support Staff 5 Posted by Tiger Team on 25 Apr, 2013 10:56 PM
Dont burn too much time-- I should be able to figure it out way faster. It seems to be restricted to PHP clients only.
Support Staff 6 Posted by Tiger Team on 25 Apr, 2013 10:57 PM
However if you are able to capture the raw http post for me that'd be suuuper helpful
7 Posted by Colin Gray on 25 Apr, 2013 10:58 PM
Thanks for looking into this. We're not using any YAML. Let us know what you find...
8 Posted by Courtenay on 25 Apr, 2013 11:30 PM
Can you give me the project id? You're posting to /tickets.xml, right?
9 Posted by Colin Gray on 25 Apr, 2013 11:34 PM
I'm posting to: /projects/90316/tickets.xml
If you can give me an email address, I can send you the php curl request dump.
10 Posted by Courtenay on 25 Apr, 2013 11:58 PM
OK, I've found the cause of it. The workaround for now is for you to hardcode the lighthouse domain and IP address so you're hitting the old load balancer - the new one (ELB) has issues with php's curl (!!)
So you'd put this in your hosts file:
replacing 'your' with your account name.
I am still trying to find the right incantation to your php script to get it working.
11 Posted by Courtenay on 26 Apr, 2013 12:31 AM
ok, turns out the original php script was crappy. Change your script to look like this:
removing the parts about content-length, $header .= $xml and so on.
Thus the whole request (based on that sample anyway) is something like
12 Posted by Colin Gray on 26 Apr, 2013 05:10 PM
Still no luck; I had tried an approach similar to this yesterday, and I constantly get back an error stating "Title can't be blank". I suspect I'm missing something obvious. Here's my test code:
Also, does your last suggestion mean we don't need the hosts file change (I've tried it both ways with no success)?
13 Posted by Julien on 26 Apr, 2013 06:02 PM
Hi Colin,
Here is a simpler, more readable version that works:
A few notes though:
I would recommend using an API token instead of user/password. simply add
X-LighthouseToken: TOKEN
to the header array, and remove theCURLOPT_USERPWD
line.I would also recomment using an XML library to generate the XML rather than handcrafting it, which is error prone.
Let me know if you have questions.
14 Posted by gazugafan on 26 Apr, 2013 07:47 PM
This new PHP code works for me!
15 Posted by Colin Gray on 26 Apr, 2013 11:19 PM
I can confirm that the new code works for us. I'd recommend placing this in your knowledge base, as well as making reference to it in the threads that have solutions that no longer work.
Thanks Julien and Courtenay!
16 Posted by Colin Gray on 27 Apr, 2013 12:43 AM
This worked for us as well. I'd recommend putting this sample in the KB and referencing it from the other thread whose approach no longer works.
Thank you Julien and Courtenay for all your help!
17 Posted by Julien on 29 Apr, 2013 05:03 PM
Hi Colin,
Courtenay pasted the correct solution in the other thread as a follow up.
Glad things are working now.
Cheers!
Julien closed this discussion on 29 Apr, 2013 05:03 PM.