Pagination for AMI Rest Call?

Added by Matt Davis 8 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
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:

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?


- Matt

Replies (3)

RE: Pagination for AMI Rest Call? - Added by Matt Davis 8 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.

curl -k -c cookies.txt "<PASSWORD>"
curl -k -b cookies.txt ""

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 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 8 months ago

Hi Matt,

theres a thread in the french forum about this problem.

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 8 months ago

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

- Matt