tag:help.lighthouseapp.com,2008-09-20:/discussions/api-developers/171-json-api-doesnt-seem-to-like-submitting-dataLighthouse: Discussion 2011-11-07T22:22:57Ztag:help.lighthouseapp.com,2008-09-20:Comment/42931672010-12-15T23:43:43Z2010-12-15T23:50:31ZJSON API doesn't seem to like submitting data<div><p>Hey all,</p>
<p>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".</p>
<p>Now, as an example, for creating a ticket bin, I send the
following JSON via a POST request to the URL <a href=
"https://mcubedsw.lighthouseapp.com/projects/64938/bins.json">https://mcubedsw.lighthouseapp.com/projects/64938/bins.json</a>
(this is a public project)</p>
<p>{<a name="true" href="{"></a><a href="">query</a></p>
<p>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.</p>
<p>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.</p>
<p>Thanks</p>
<p>Martin</p></div>Martin Pilkingtontag:help.lighthouseapp.com,2008-09-20:Comment/42931672010-12-16T10:34:56Z2010-12-16T10:34:56ZJSON API doesn't seem to like submitting data<div><p>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.</p></div>Martin Pilkingtontag:help.lighthouseapp.com,2008-09-20:Comment/42931672010-12-16T20:22:39Z2010-12-16T20:22:39ZJSON API doesn't seem to like submitting data<div><p>I had a look at this yesterday, but I didn't test ticket bins.
I'm investigating and I'll let you know something.</p></div>Justin Palmertag:help.lighthouseapp.com,2008-09-20:Comment/42931672010-12-16T21:54:30Z2010-12-16T21:54:30ZJSON API doesn't seem to like submitting data<div><p>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.</p>
<p>Here is what's working for me using curl.</p>
<pre>
<code>justin@justin ~% curl -H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"bin":{"name":"My TITLE","query": "state:open"}}' \
"http://activereload.local.i:3000/projects/2/bins.json?_token=c7fe4e1d9f492321885b042819f3f6225133fc0a"</code>
</pre>
<p>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'.</p></div>Justin Palmer