Project

General

Profile

Pagination for AMI Rest Call?

Added by Matt Davis about 2 months ago

Hi There,

I am running the following REST request to get all the sip peer statuses. (Who has their phone connected, their phone is reachable, etc)

I do a POST call to "https://MYASTERISKIP:9491/1.0/action/SIPpeerstatus"

It returns the data just fine but stops at only 37 peers (38 response items) and I don't know how to get to the next section...

1) start, Peer status will follow, Success
2) FIRST PEER HERE
...
38) 37th PEER HERE

I don't ever get the rest or the "EventList: end" that I get when I am asked for a smaller subset of data.

How would I paginate this request? I read about the pagination for GET requests here: http://documentation.wazo.community/en/stable/api_sdk/rest_api/conventions.html#general-url-parameters

But that does not work for this POST request... I would love to grow the limit higher but I would live with pagination if it's necessary.

The total peer list is around 69 peers.

When I run "sip show peers" in the asterisk command line, I get all of them just fine.

Can anyone direct me with what I need to do to get the rest of the data through this REST call?

Thanks!

- Matt


Replies (3)

RE: Pagination for AMI Rest Call? - Added by Matt Davis about 2 months ago

Just to give some more info...

When I use asterisk's AJAM directly it is also "truncated" or limited just like the REST call.

ie:
curl -k -c cookies.txt "https://127.0.0.1:5040/rawman?action=login&username=xivo_amid&secret=<PASSWORD>"
curl -k -b cookies.txt "https://127.0.0.1:5040/rawman?action=SIPpeerstatus"

This results in the same limited info that stops around peer 37.

If I use asterisk's AMI then I get the full response NOT truncated.

ie: telnet 127.0.0.1 5038

Action: login
Username: xivo_amid
Secret: <PASSWORD>

Action: SIPpeerstatus

Then in the terminal I see all responses.

I will need to go on asterisk's forum and find out how to increase the response size of AJAM requests or find out how to properly request the next page if I don't read "Event: SIPpeerstatusComplete" when getting the info.

- Matt

RE: Pagination for AMI Rest Call? - Added by Pascal Cadotte-Michaud about 2 months ago

Hi Matt,

theres a thread in the french forum about this problem.

https://projects.wazo.community/boards/8/topics/14383?r=14482#message-14482

As you discovered, this is an Asterisk bug. Theres a packaged version of Asterisk 15.6.1 in the linked thread that you can install to work around this problem.

RE: Pagination for AMI Rest Call? - Added by Matt Davis about 2 months ago

Awesome! I will need to try this out over the weekend and I will report back.

Thanks,
- Matt

    (1-3/3)