FreePBX modify queue using API results in 405


(Gai1ahg7bei Th9a) #1

Hi,

According to the freepbx issue #22294 (unfortunately I can’t post the link due to forum restrictions) it should be possible to modify the queue member using a PUT against admin/api/api/rest/queues/members/xyz

I’m getting a 405 - Method not allowed though when trying to add a member to the queue.

We are using FreePBX 15.0.17.43 and Version 15.0.33 of the queues Module.

Does anyone have experience with this API Call or could direct us in the right direction ?


(Itzik) #2

Are you using the latest version of the API and Core module?

Please show us your API request and response.

(For reference. OP is referring to this ticket: https://issues.freepbx.org/browse/FREEPBX-22294
Thank you @sholinaty for your contributions!)


(Gai1ahg7bei Th9a) #3

I’m using the following API request:

curl --request PUT --url https://pbx01.xyz.com/admin/api/api/rest/queues/5555 \
  --header 'Authorization: Bearer xyz \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --cookie PHPSESSID=dtndcfkf7i648n732dqgeg2815 \
  --data member=332

Response:

HTTP/1.1 405 Method Not Allowed
Date: Tue, 17 Aug 2021 12:00:11 GMT
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/5.6.40
X-Powered-By: PHP/5.6.40
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Allow: GET
Content-Length: 555
Content-Type: text/html;charset=UTF-8

<html>
    <head>
        <title>Method not allowed</title>
        <style>
            body{
                margin:0;
                padding:30px;
                font:12px/1.5 Helvetica,Arial,Verdana,sans-serif;
            }
            h1{
                margin:0;
                font-size:48px;
                font-weight:normal;
                line-height:48px;
            }
        </style>
    </head>
    <body>
        <h1>Method not allowed</h1>
        <p>Method not allowed. Must be one of: <strong>GET</strong></p>
    </body>
</html>

We are using API Version “REST API 13.0.21.2” and Core Version 15.0.12.73


(Sholinaty) #4

I’ll look up the syntax needed for this api call and share it shortly. I think you might be on a lower version than this change however.


(Sholinaty) #5

Second thought… might be a post and not a put. Will verify


(Gai1ahg7bei Th9a) #6

I tried POST and PUT but the result is the same


(Sholinaty) #7

from my testing:
this was introduced in QUEUES version 15.0.28:, so you should be good there.

my test uses a PUT… you’re good there…
‘contentType’:‘application/x-www-form-urlencoded’

one thing of note - your API is to HTTPS… my test was on HTTP.
http://domain.tld/admin/api/api/rest/queues/update/999

Thats it!

your path is missing the /update/ before the queue ID.


(Gai1ahg7bei Th9a) #8

Thanks but this results in a 404. What works is a GET against the url (without the /update/). This returns a json body with information about the queue


(Sholinaty) #9

do you have any pending updates to the CORE or API modules?


(Gai1ahg7bei Th9a) #10

yes but they only look like minor updates

Core 15.0.12.73 Stable Sangoma Technologies Corporation [GPLv3+](http://www.gnu.org/licenses/gpl-3.0.txt) Online upgrade available (15.0.12.74)
PBX API 15.0.3.15 Stable Sangoma Technologies Corporation [AGPLv3+](http://www.gnu.org/licenses/gpl-3.0.txt) Online upgrade available (15.0.3.16)
Asterisk API 15.0.12 Stable Sangoma Technologies Corporation [GPLv2+](https://www.gnu.org/licenses/gpl-2.0.txt) Enabled and up to date
REST API 13.0.21.2 Stable Sangoma Technologies Corporation [AGPLv3](http://www.gnu.org/licenses/agpl-3.0.txt) Enabled; Not available online

(Itzik) #11

Update it!


(Sholinaty) #12

core is only 1 minor version behind, and should be new enough to work…
pbx API is only 1 minor behind…
asterisk API is on the same one I have…

are you sure you’re on queues 15.0.33 ? that’s not a pending update?
can you go the web gui, and go to admin > Module admin
expand Queues
and take a screenshot please?


(Sholinaty) #13

here is a curl that is working today.
im using Postman to make the requests, but it outputs the curl nicely.

curl --location --request PUT 'http://server-domain.tld/admin/api/api/rest/queues/members/999' \
--header 'Authorization: Bearer {removed my oauth2 token}' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Cookie: PHPSESSID=50fe2j53po6d1i36aam5vorhd6' \
--data-urlencode 'member=5133' \
--data-urlencode 'dynmembers=142'

edit note: member and dynmembers, i had the plural backwards.

i guess thats the other question - is your API Key authorized for REST? and have you generated the oauth2 token from your api key? that error could be that your key isnt authorized to use REST


(Gai1ahg7bei Th9a) #14

The /members/ was missing in my curl. It seems to be working now. Thank you!


(system) closed #15

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.