avatar mkornblum Nov 12. 2009. 6:34 pm
Hi,

I'm trying to develop an arduino-based hardware 'button' for recording time against tickets.

I've built an AS3 AIR client for AC which successfully gets all the projects and tickets I need, but I've been struggling for days now to post a new time record.

I'm sending the submitted=submitted, token and path_info vars as GET on the end of the query string, and the time[xxx] as POST. If I do anything else I get a validation error, and this seems the right format from browsing these forums. The API is read-write enabled.

Here's a raw request header as an example:

POST /api.php?token=xxxxxxxxxxxxxxxxxx&path_info=/projects/53/time/add&submitted=submitted HTTP/1.1
Host: xxxxxxxxxxxxxx
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/523+ (KHTML, like Gecko) AdobeAIR/1.1
Referer: app:/ArduinoCollab.swf
X-Flash-Version: 9,0,124,0
Accept: */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Cookie: PHPSESSID=h5ektpbgc5f1b26fqd75f58m71; X-Mapping-hppgikmp=85AE45C9C376FCA50012721BE0710536
Content-Length: 83
Connection: keep-alive

time%5Buser%5Fid%5D=9&time%5Bvalue%5D=5%3A30&time%5Brecord%5Fdate%5D=2009%2D11%2D13

I'm sending:

time[user_id]=9
time[value]=5:30
time[record_date]=2009-11-13

Can anyone see anything wrong with this? Any help gratefully received!!
avatar mkornblum Nov 12. 2009. 6:35 pm
I forgot to mention - this request simply gives me a '400 Bad Request' error...
avatar Ilija Studen Staff Nov 13. 2009. 8:56 am
submitted=submitted should be POST, not GET variable.
avatar mkornblum Nov 13. 2009. 6:40 pm
Great, that worked - thanks Ilija. Is there an API quickstart guide - it took me a long time to figure out all the little quirks, and it might be useful for others...
avatar Ilija Studen Staff Nov 16. 2009. 9:49 pm
We'll see to make use of API easier in the future for developers. Can you please tell me which platform do you use? PHP, .NET, Java? Something else?
avatar mkornblum Nov 17. 2009. 4:01 am
I'm a PHP developer usually, but have been learning AS3 to make an AIR app that communicates with the API.

AS3 doesn't easily create variables in the format that the API needs (e.g. time[value] as a POST var) - you need a little hack in order to do this, just so you know ;-)
avatar Ilija Studen Staff Nov 18. 2009. 5:43 am
Good to know, thanks :)