Summary:ASTERISK-22685: Unable to POST content-type: application/json to ARI
Reporter:Paul Belanger (pabelanger)Labels:
Date Opened:2013-10-13 19:22:17Date Closed:2013-11-27 09:44:03.000-0600
Versions:12.0.0-beta1 Frequency of
is related toASTERISK-22697 ARI: Add the ability to raise an arbitrary User Event from the Asterisk or Applications resource
Description:After some initial testing, it looks like support for POSTing content as json to ARI is not supported.

$ curl -i -X POST -H 'Content-Type: application/json' -H 'Authorization: Basic x1x2x3' -H 'Accept: application/json' -H 'User-Agent: python-ari' -d '{"endpoint": "local/1"}' http://localhost:8088/ari/channels

HTTP/1.1 400 Bad Request
content-length: 45
server: Asterisk/SVN-trunk-r396505M
connection: close
cache-control: no-cache, no-store
date: Sun, 13 Oct 2013 23:03:14 GMT
content-type: application/json

 "message": "Endpoint must be specified"

From a library point of view, it would be great to keep the data formatted constantly throughout vs converting it for different HTTP actions.
Comments:By: David M. Lee (dlee) 2013-10-14 09:35:44.958-0500

For the initial version of the API, only query and path parameters are supported. Yes, I feel a bit gross POSTing with query parameters, but that's where we are today.

$ curl -i -X POST -H 'Content-Type: application/json' -H 'Authorization: Basic x1x2x3' -H 'Accept: application/json' -H 'User-Agent: python-ari' 'http://localhost:8088/ari/channels?endpoint=local/1'

So I would call this a 'feature request' instead of a 'bug'.

By: Matt Jordan (mjordan) 2013-10-15 15:51:57.231-0500

I'd say it's an improvement as well, but one we're going to need for both UserEvents from ARI as well as other resources (MWI, Device State, etc.)