CallerID API¶
-
apirest.callerid_serializers.
CallerIDSerializer
¶ Create:
CURL Usage:
curl -u username:password --dump-header - -H "Content-Type:application/json" -X POST --data '{"areacode": "+1203", "callerid_num": "+120388445522", "callerid_group": "/rest-api/callerid_group/1/"}' http://HOSTNAME_IP/rest-api/callerid/
Response:
HTTP/1.0 201 CREATED Date: Fri, 14 Jun 2013 09:52:27 GMT Server: WSGIServer/0.1 Python/2.7.3 Vary: Accept, Accept-Language, Cookie Content-Type: application/json; charset=utf-8 Content-Language: en-us Allow: GET, POST, HEAD, OPTIONS
Read:
CURL Usage:
curl -u username:password -H 'Accept: application/json' http://HOSTNAME_IP/rest-api/callerid/ curl -u username:password -H 'Accept: application/json' http://HOSTNAME_IP/rest-api/callerid/%callerid-id%/
Response:
{ "count": 2, "next": null, "previous": null, "results": [ { "url": "http://127.0.0.1:8000/rest-api/callerid/3/", "areacode": "*", "callerid_num": "Replace me!", "callerid_name": "", "created_date": "2018-09-20T10:37:58.353565+02:00", "callerid_group": "http://127.0.0.1:8000/rest-api/callerid_group/3/" }, { "url": "http://127.0.0.1:8000/rest-api/callerid/4/", "areacode": "*", "callerid_num": "Replace me!", "callerid_name": "", "created_date": "2018-12-04T12:17:31.393851+01:00", "callerid_group": "http://127.0.0.1:8000/rest-api/callerid_group/4/" } ] }
Update:
CURL Usage:
curl -u username:password --dump-header - -H "Content-Type: application/json" -X PATCH --data '{"callerid_num": "+120388445599"}' http://HOSTNAME_IP/rest-api/callerid/%callerid-id%/
Response:
HTTP/1.0 202 NO CONTENT Date: Fri, 23 Sep 2011 06:46:12 GMT Server: WSGIServer/0.1 Python/2.7.1+ Vary: Accept-Language, Cookie Content-Length: 0 Content-Type: text/html; charset=utf-8 Content-Language: en-us
Delete:
CURL Usage:
curl -u username:password --dump-header - -H "Content-Type: application/json" -X DELETE http://HOSTNAME_IP/rest-api/callerid/%callerid-id%/
How to filter and update a specific CallerID:
The CallerID has 3 filters: callerid_group_id, areacode & callerid_num.
You can use none or several of those filters to retrieve a specific callerID.
Here an example of retrieving the CallerID Number +120388445511 in the CallerID Group 1:
curl -u username:password -H 'Accept: application/json' http://127.0.0.1:8000/rest-api/callerid/?callerid_group_id=1&areacode=&callerid_num=%2B120388445511
The result might be as bellow:
{ "count": 1, "next": null, "previous": null, "results": [ { "url": "http://127.0.0.1:8000/rest-api/callerid/3/", "areacode": "+1203", "callerid_num": "+120388445511", "callerid_name": "", "created_date": "2021-12-15T11:19:41.234374+01:00", "callerid_group": "http://127.0.0.1:8000/rest-api/callerid_group/1/" } ] }
Now, if you want to update the callerID you just retrieved, you can use the CallerID ID from the url, here it’s 3.
Update that callerid_num to a new value, for instance 120388445511 as follow:
curl -u username:password --dump-header - -H "Content-Type: application/json" -X PATCH --data '{"callerid_num": "+120388445511"}' http://127.0.0.1:8000/rest-api/callerid/3/
The CallerID has now been updated.