Skip to main content
Question

Subscribe to SMS Events

  • August 25, 2023
  • 1 reply
  • 134 views

Subscribing to a message event is giving me a hard time. I have set up webhook notifications for my account before but a previous integration was failing so I had to remove my old subscription and create a new one to test with locally. Now when I go to subscribe to the webhook using the extensions credentials to sign in, the process responds back with an error message "403 - Forbidden" "Not allowed to subscribe for events of other account". I don't know how this could be though since I am signing in as myself to subscribe to an event.

platform.login({
    "username": 1234567890,
    "password": "nOTmyPaSsword",
    "extension": 999
})

platform.on(platform.events.loginSuccess, async ()=>{
    var body = {
        eventFilters: [
            "/restapi/v1.0/account/1234567890/extension/999/message-store/instant?type=SMS"
        ],
        expiresIn: 315360000,
        "deliveryMode": {
            "transportType": "WebHook",
            "address": "https://bigtest.ngrok-free.app/ring-central",
            "verificationToken": "verificationTOKEN"
        }
    }
    var respose = await platform.post("/restapi/v1.0/subscription", body);
    var json = await respose.json();
    console.log(json);
})

If it really helps I can expose the extension and number (just not the password obviously) but this is what I have been using to try and subscribe to an event. I am logging in with the extension and then if I log in successfully, subscribe. I am able to log-in successfully as I am logging successes back to the console, but as I said earlier, the API returns a 404 Forbidden Response. Is there something that I am inherently missing?

1 reply

PhongVu
Community Manager
Forum|alt.badge.img
  • Community Manager
  • 2312 replies
  • August 25, 2023

This is the key problem.

eventFilters: [
            "/restapi/v1.0/account/1234567890/extension/999/message-store/instant?type=SMS"
        ]

And the error message told you the reason:

error message "403 - Forbidden" "Not allowed to subscribe for events of other account"

The API reference shows you this. The account Id and the extension Id (Not extension number 999 as in your code.

/restapi/v1.0/account/{accountId}/extension/{extensionId}/message-store

If you don't know the account Id nor the extension Id, simple use the tilde like this

/restapi/v1.0/account/~/extension/~/message-store

Check the dev guide for sample code


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings