Skip to main content

Hello,

Can one App have multiple notification subscriptions for multiple delivery addresses by running the subscription request setup again for each new address? This can occur when an application changes environments (test, UAT, Production, etc.)

I don't know what you want to achieve. But you can specify one delivery address per subscription. You can subscribe max. 20 subscriptions and notifications will be sent to the delivery addresses as long as those subscriptions are active.


Thanks Phong for clarifying this.

We are having an issue subscribing to fax notifications. The error returned is not specific:

Content: {"errorCode":"SUB-522","message":"WebHook responds with incorrect HTTP status. HTTP status is 400","errors":[{"errorCode":"SUB-522","message":"WebHook responds with incorrect HTTP status. HTTP status is 400","status":"400"}],"status":"400"}

Our deliveryMode.address is on the internet and works when I post a payload from Postman but of course will return an error if there is no payload posted. We are getting and setting the Validation_Token in our API Controller.

Here is our webhook setup C# code that is throwing the error:

SubscriptionInfo subscriptionInfo = await restClient.Restapi().Subscription().Post(new CreateSubscriptionRequest

{

eventFilters = new[] { "/restapi/v1.0/account/~/extension/~/fax?direction=Inbound" },

expiresIn = 630720000, //20 years

deliveryMode = new NotificationDeliveryModeRequest

{

transportType = "WebHook",

address = "https://services-tst.americanportfolios.com/RingCentralAPI/fax/received", }

});


And Webhook C# API controller code that will receive the notifications:


[HttpPost("received")] //From RingCentral

public async Task GetFaxReceived([FromBody] dynamic eventPayload)

{

string str = HttpContext.Request.Headers["Validation_Token"];

await ringCentralProvider.GetFaxReceivedAsync(eventPayload); //just handles the payload

HttpContext.Response.Headers.Add("Validation_Token", str);

}


What are we doing wrong that you can see?

Thanks.


Can you try moving up the code to return the validation token like this

[HttpPost("received")] //From RingCentral
public async Task GetFaxReceived([FromBody] dynamic eventPayload)
{
string str = HttpContext.Request.Headers["Validation_Token"];
HttpContext.Response.Headers.Add("Validation_Token", str);
await ringCentralProvider.GetFaxReceivedAsync(eventPayload); //just handles the payload
}

Hi Phong - I moved the code as you suggested but that did not resolve the issue.

Below is the full error. The error content does not provide any specific details. Does the subscription request actually call the deliveryMode.address endpoint or is this error coming from the RingCentral side? Please review the request details for any missing or incorrect data.

Thank you.


Response:

StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:

{

Server: nginx

Date: Fri, 04 Jun 2021 19:45:54 GMT

Transfer-Encoding: chunked

Connection: keep-alive

LocalHostInfo: 10.28.28.28__1372@sjc11-c01-csg03.devtest.ringcentral.com

RCRequestId: 797aa190-c56d-11eb-856a-005056bbb10f

X-ERROR-ID: 797aa190-c56d-11eb-856a-005056bbb10f

X-Rate-Limit-Group: medium

X-Rate-Limit-Limit: 40

X-Rate-Limit-Remaining: 39

X-Rate-Limit-Window: 60

RoutingKey: SJC11P01

Content-Type: application/json; charset=UTF-8

}

Content: {"errorCode":"SUB-522","message":"WebHook responds with incorrect HTTP status. HTTP status is 400","errors":[{"errorCode":"SUB-522","message":"WebHook responds with incorrect HTTP status. HTTP status is 400","status":"400"}],"status":"400"}


Request:

Method: POST, RequestUri: 'https://platform.devtest.ringcentral.com/restapi/v1.0/subscription', Version: 1.1, Content: System.Net.Http.StringContent, Headers:

{

X-User-Agent: Unknown/0.0.1 RingCentral.Net/5.2.0

Authorization: Bearer U0pDMTFQMDFQQVMwMHxBQUQ5MEpzbGU0VHpUUDVGaG0wYWdnU0NrY3B1SjU5NHk3dzROQWFqME1OeEltYmNNbUhJZlAyMzZvSjhmRmY5ekxFalVuMEdOSTZ1d0F4d1JMRzZsaVU4dzRuR3ZyaEYtMnQ0NXhCUHZmcDFwQkRndmV3dGhqSU4wNUd3Ui1pQmR3cmtXSU4wOTZFQ1hhWFp5eDFMRWVyeUFuY1hXSmQzM2RXbUk3T0VEU19IbGNCcDdlYm1MTUNzeDlfcU03dmZSbDh8YVg4TVRnfERRODlXWmE2dm1zSzRLc1Z4aXBXcGd8QVE

Content-Type: application/json; charset=utf-8

Content-Length: 227

}

Content: {"eventFilters":["/restapi/v1.0/account/~/extension/~/fax?direction=Inbound"],"deliveryMode":{"transportType":"WebHook","address":"https://services-tst.americanportfolios.com/RingCentralAPI/fax/received"},"expiresIn":630720000}



This answer may help you. https://community.ringcentral.com/questions/888/unable-to-create-webhook-subscription.html


Hi Phong - The link you sent is not helpful. Our webhook is working but is returning a 400 error in response to the subscription request.

The documentation link in the page you reference is no longer valid and the code link contains no useful code.

Are there recent working code examples or other documentation that I can review?

Thanks.


How about using the sample code here. And or try first in your local host using ngrok tunnel.


Reply