How to add secret in extension at the time creation via GraphQL

I don’t see any way of specifying the SIP password in that documentation. Also, is there any timeline/roadmap for adding the ability to set other parameters not listed in the documentation for SIP devices (like the accountcode especially in my case!)…

In addition, does not seem like any support yet for Inbound Routes, FollowMe or User Manager?

Normally you would let the PBX generate a password, same with the API.

The API is constantly being worked on (you can start watching these Wiki pages to get notified when there is new changes)
The good new is, AFAIK, the API is open source, so if something is missing that you desperately need, you can write it and then contribute it!

Not when you are programmatically creating one. Because whatever system that is creating the extension will have a password it wants to set the extension to that it will use for the OTHER things it is doing.

1 Like

Woo-hoo! The documentation has been updated:

https://wiki.freepbx.org/display/FPG/Core+Module+GraphQL+APIs

With a new option of:

extPassword: "secret"

API Request

GQLAPI: /admin/api/api/gql
 
Parameters:
 
  mutation {
    updateExtension(
        input: {
            extensionId: 9090090111
            name: "api test"
            tech: "pjsip"
            channelName: "APi Test2"
            outboundCid: "12345678901"
            email: "xyzabc@gmailcom"
            umGroups: "1"
            umEnable: true
            umPassword: "password"
            vmPassword: "password"
            vmEnable: true
            callerID: "234234324"
            emergencyCid: "1221333331"
            clientMutationId: "test1231"
            extPassword: "secret"
        }
      ) {
            status
            message
            clientMutationId
       }
}

API Response

{
  "data": {
    "updateExtension": {
      "status": true,
      "message": "Extension has been updated",
      "clientMutationId": "test1231"
    }
  }
}
4 Likes

The other reason one might want/need to specify the password is that the organization might have specific password complexity requirements so good to be able to manually specify it.

1 Like

I’ve been looking at how to programmatically set the extension “secret” for some time.
I was delighted when I saw the “extPassword” option. But I can’t get it to work. I get :
“Field “extPassword” is not defined by type updateExtensionInput; Did you mean vmPassword?”
I have updated the PBX API module to 15.0.3.12
Any ideas ?

Make sure you run api and core in latest edge

I’m not sure I follow. “Edge” as in the browser ??
I’m developing the GraphQL in Insomina before implementing in a c# desktop app.
I get the same error when using the FreePBX GraphQL explorer in both Chrome and Edge.

Usually, when someone here is referring to edge, they are referring to the edge repository.

https://wiki.freepbx.org/display/FPG/Edge+vs+Stable

fwconsole ma upgrade <module> --edge
1 Like

As @PitzKey says, this is a new feature and requires very new versions of the API and core modules. Update from edge repo.

It’s great to see people actively discussing and using the API we’ve been adding. As I’ve written before, this is one of the focuses for FreePBX 16, and where possible, new 16 features are being backported to previous version(s).

3 Likes

Thanks @lgaetz and @PitzKey

I couldn’t get it to offer me the option of using edge repositories - despite setting “Module admin to edge mode”.
However - the problem seems to have disappeared. I can now create extensions with a secret of my choice.
Or so I thought - the secret displayed in the GUI doesn’t seem to have changed.
I would check - but the query I was using to extract the secret has now stopped working :

    tech {
      __typename... on pjsip{secret}
    }

Now returns :

“Field “tech” of type “String!” must not have a sub selection.”

To perhaps clarify what I am trying to do :
The aim is to have an app or web page provision extensions with minimal details. Those details being what a user would enter when logging into a softphone.

1 Like

Ran into this too, running
Asterisk 16.17.0
FreePBX 15.0.17.34
PBX API 15.0.3.12

extPassword
I get:

“message”: “Cannot query field "extPassword" on type "coreuser". Did you mean "password"?”

But “fetchAllExtensions” works with all the other fields

Does not work.
Also tried Greg’s sample code:

{
  fetchExtension(extensionId: "4033") {
    status
    message
    extensionId
    user {      extPassword    }
  }
}

Result:

{
“errors”: [
{
“message”: “Cannot query field "extPassword" on type "coreuser". Did you mean "password"?”,
“status”: false
}
]
}

Modules on the latest edge version?

Yes. I do “fwconsole ma upgrade --edge framework api certman firewall sysadmin” before I start working every time

@yahdie But the modules you need on edge as mentioned in my linked post are core, userman, and api. Your command only had “api” from those 3. Please try it again with core and userman at edge. Just tried it with these versions, still working:

#fwconsole ma list |egrep "core|api|userman"
     | api                  | 15.0.3.15  | Enabled                           | AGPLv3+     
     | core                 | 15.0.12.71 | Enabled                           | GPLv3+      |
     | userman              | 15.0.41    | Enabled                           | AGPLv3+     |

@gblumenthal Thank you for pointing this out.
Everything works now

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