question

bob-cross avatar image
bob-cross asked Phong Vu commented

Need to Build Custom Answering Rule in Windows Forms App

I need to be able to build an app that pulls phone numbers from my CRM along with the "handling rep," then creates a custom answering rule with that info so that anyone calling with a number matching that list, gets routed to their rep. I'm a VB programmer so I am trying to use C# and convert it but I can't initialize the RestClient. If I pull the example in C# and put it in a C# project I also get errors. I'm trying to use the RingCentral.Net version 5.11.0 from GitHub.

call queues
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image
Phong Vu answered bob-cross commented

This much info will not help us to help you. Can you share some code around where you got stuck so people can help.

1 comment
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Imports RingCentral

Public Class Form1

Shared restClient As RestClient

Private Sub CreateCustomAnsweringRule()

Try

restClient = New RingCentral.RestClient(RINGCENTRAL_CLIENTID, RINGCENTRAL_CLIENTSECRET, RestClient.SandboxServer)

restClient.Authorize(MYUSERNAME, MYSANDBOXEXTENSION, MYPASSWORD).Wait()

create_company_custom_answering_rule().Wait()

Catch ex As Exception

MessageBox.Show("1: " & ex.Message)

End Try

End Sub

Private Shared Async Function create_company_custom_answering_rule() As Task

...Insert parameter code here (it was too long to post)

Dim response = Await restClient.Restapi().Account().AnsweringRule().Post(parameters)

'Had to comment this next line out because I get an error 'JsonConvert' is not declared. It may be unaccessible due to its protection level.

'Dim jsonStr = JsonConvert.SerializeObject(response)

End Function

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Try

CreateCustomAnsweringRule()

Catch ex As Exception

MessageBox.Show("3: " & ex.Message)

End Try

End Sub

The code fails on the restClient = New RestClient line with the following error.

The type initializer for RingCentral.RestClient threw an exception.

0 Likes 0 ·
bob-cross avatar image
bob-cross answered Phong Vu commented

Anyone want to help?

1 comment
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

I guess that no one in this forum would have experience in using a .NET lib wrapped in VBA. Can you create a .NET project and test pure C# code to see if you could create the SDK instance and login.

0 Likes 0 ·