Trying this code to send SMS in C# it is throwing a CS0103 at this point:
var response = await extension.Sms().Post(requestBody); //name extension does not exist in current context.
The full code
public async void sendSms()
{
RestClient rc;
rc = new RestClient("id, "clientsecret", "https://platform.devtest.ringcentral.com");
var requestBody = new
{
text = "Test",
from = new { textFrom = "+15551212" },
to = new object[] { new { sendTo = "+15551231" } }
};
var response = await extension.Sms().Post(requestBody); //Can't get past this point.
}
Neither do I, That is not where I am getting the info from, I am using this. And there is no provision for adding a direct number?? I tried this with Python and it it worked fine...has something changed?
After the code below, can you print the "resp" object as string and post it here.
var resp = await restClient.Restapi().Account().Extension().PhoneNumber().Get();
No, It is throwing CompanyPhoneNumberInfo does not contain a definition for 'for 'records'
I tried changing it to this:
CompanyPhoneNumberInfo resp = await restClient.Restapi().Account().Extension().PhoneNumber().Get();
then in the foreach I tried this:
foreach (CompanyPhoneNumberInfo record in resp.records)
{
foreach (CompanyPhoneNumberInfo feature in record.features)
{
Same exception.
I asked you to print the response, not parsing it w/o knowing what it returns.
var response = await rc.Restapi().Account().Extension().PhoneNumber().Get(); dynamic jsonStr = JsonConvert.SerializeObject(response); Console.WriteLine(jsonStr);
The site you visit is the RingCentral Developer portal. It is different than the sandbox account admin portal. To setup and config your sandbox such as adding new users, adding new numbers ect. you need to login https://service.devtest.ringcentral.com with your sandbox user's login credentials (not the login credentials for the dev portal!). Alternatively, you can click the "Sandbox Accounts" option from the view you showed above and click on the up-arrow which will log you in the sandbox admin portal.
I will investigate the C# later.
Okay, I see it now, I will have to get the password from them, strange something has changed as I was able to use the information above to send SMS (with Python). As far as the C# goes the only error(s) I could find where in the foreach statements.
Thanks
Nothing, It freezes. No exceptions nothing.
Once you could try Python code, can you use this Python code?
https://developers.ringcentral.com/guide/messaging/quick-start#python
Thanks, I think I will try convincing them to use Python instead.
Don't need to. I just want to see the differences between using the .Net SDK and the Python SDK in your particular case.
BTW, what is the RingCentral .Net SDK version are you using?
v4.0.30319
I am not aware of a version .30319. The current version is 4.1.0. Can you update the SDK
Okay, it's now v4.0.30319
Not much luck with python either I am getting
ringcentral.http.api_exception.ApiException: Unauthorized for this grant type
you got to try with this app instead "SMSSendTest5". This app is password flow and should work with the sample code authentication.
Im really not having much luck
In python
ringcentral.http.api_exception.ApiException: In order to call this API endpoint, application needs to have [ReadAccounts] permission
Tried changing it in the C# version as well but that foreach is still jamming me up.
Then add the ReadAccounts permission to the app
Also, it look like this app "ChiliSMS" has more serious problem. It has no permissions at all.
Please go thru our dev guide and documentation to learn basic steps.
Okay,
Now it's working...I will delete ChiliSMS, not sure who put that there. Anything on that foreach statement:
foreach (var record in resp.records) I think it will work if I can get past that...
Same result; CS1061 CompanyPhoneNumberInfo does not contain a definition for records
Comment out the foreach lines! Just print the response which will not have anything to do with the CompanyPhoneNumberInfo object.
I am usinh 3136362490
I don't know why the phone-number endpoint return null from your account. It should at least return the main company number. But looking into your sandbox account, I see you don't have any other number added to the user "101".
You can login your sandbox service web, browse to the page as shown above, then click the Add Direct Number and follow the instructions to add a number to the user extension.
Test it again.
Check out this quick start sample code to use the SDK for sending SMS messages.
https://developers.ringcentral.com/guide/messaging/quick-start#c#
Thanks, There seems to be a problem in
static private async Task read_extension_phone_number()
here
foreach (var record in resp.records) //This throws CS1061
//CompanyPhoneNumberInfo does not contain a definition for 'records'
there are also some other problems with the record variable
Looks like your test account does not have any number. Can you check if the resp.records is null or an empty array?
Thanks, Can't tell it's telling me resp has nothing like records or features there is no definition for either one in the foreach. Anyway I looked at the account and there is a number for the account, is that it?
What is your sandbox account main company number?
A new Community is coming to RingCentral!
Posts are currently read-only as we transition into our new platform.We thank you for your patience
during this downtime.
Try Workflow Builder
Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!Try RingCentral Workflow Builder