JSON API doesn't seem to like submitting data

Martin Pilkington's Avatar

Martin Pilkington

15 Dec, 2010 11:43 PM

Hey all,

I'm in the process of switching over from the XML to the JSON API. It is working great for reading data, but I seem to have hit a snag for writing data. Now I have re-written a lot of code, but the basics are the same and effectively I have just swapped the XML HTTP body with a JSON equivalent, the .xml at the end of the URL with a .json and change the content type to "application/json".

Now, as an example, for creating a ticket bin, I send the following JSON via a POST request to the URL https://mcubedsw.lighthouseapp.com/projects/64938/bins.json (this is a public project)

{"ticket-bin":{"name":"Open Tickets","query":"state:open","default":false}}

Now while it works in XML, with JSON it seems to send back a 500 response. Now I'm not sure whether the JSON API is buggy, or I'm doing something wrong, as the documentation doesn't mention it at all and I'm working out the JSON to spend from a mixture of what I can read through a GET and the XML docs.

I haven't yet tried doing a PUT or DELETE yet, nor anything other than ticket bins. I'm going to try some others tomorrow and see if it is the whole API or just this bit. I can work around this by sending data as XML, but I'd prefer to use the JSON API everywhere.



  1. 1 Posted by Martin Pilkingt... on 16 Dec, 2010 10:34 AM

    Martin Pilkington's Avatar

    OK, some more information. Milestones works fine. It's just ticket bins that has a 500 on creation. It also gives a 200 back on update (PUT) but it doesn't actually update it on the site.

  2. 2 Posted by Justin Palmer on 16 Dec, 2010 08:22 PM

    Justin Palmer's Avatar

    I had a look at this yesterday, but I didn't test ticket bins. I'm investigating and I'll let you know something.

  3. 3 Posted by Justin Palmer on 16 Dec, 2010 09:54 PM

    Justin Palmer's Avatar

    Got a little further with this. I was able to create a ticket bin, but had to make a small change. The namespace will be "bin" vs "ticket-bin" in your JSON.

    Here is what's working for me using curl.

    justin@justin ~% curl -H "Accept: application/json" \
    -H "Content-Type: application/json" \
    -d '{"bin":{"name":"My TITLE","query": "state:open"}}' \

    This doesn't explain the 200 you're seeing on a PUT, but that might be some side effect (albeit, the wrong one) of not using 'bin'.

  4. Martin Pilkington closed this discussion on 15 Apr, 2011 06:37 PM.

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

Keyboard shortcuts


? 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