News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
App stops after SMS API Call
Tags: rest api
Sep 16, 2021 at 4:42am   •   2 replies  •  0 likes
Super Admin

I am having an interesting issue when sending an SMS message. I am currently using the C# SDK and testing through the sandbox.

I'm not sure if it's because of the size of the message or what. If I just have the "Hello from C#", it sends the message, but if I try to add my own message, it will call the SMS endpoint and then my program stops. Not in an error stop way, but it shuts off the debugger.

For the message, I have kept it under 160 characters, including the "watermark" text you all add to the front while sending in sandbox. I have the call in a try/catch and it's odd that if the call is erroring out, it would have been caught in the catch block.

Code Example:

 var parameters = new CreateSMSMessage
                {
                    from = new MessageStoreCallerInfoRequest { phoneNumber = fromNumber },
                    to = new MessageStoreCallerInfoRequest[] { new MessageStoreCallerInfoRequest { phoneNumber = phone} },
                    text = $"To see your results use access key - Access Key: {accessKey} - https://bit.ly/whatever"
                };
try
{
    //This is the call that after it executes, it will stop Visual Studio debugging
    //It shows as a success in analytics, but doesn't send a message
    var resp = await ringCentral.Restapi().Account().Extension().Sms().Post(parameters);
    var msgStatus = resp.messageStatus;
}
catch(Exception ex)
{
   //Handling the exception
}

UPDATE: It is also doing it when I use the "Hello from C#" as the text parameter. It's probably not a text message size issue, but nothing is throwing an error.

2 Answers
answered on Sep 16, 2021 at 11:55am  

I got it working. The request client was being passed into a method and apparently that is not allowed. Weird it wouldn't throw an error though.


 0
answered on Sep 16, 2021 at 7:19am  

I believe that your message failed because or the shortened link bit.ly. Try with a full domain link or test https://google.com/whatever.


 0
on Sep 16, 2021 at 7:41am   •  0 likes

It's still doing it without any link added to it. I put in "Hello from C#" in the text parameter and the same thing happened

on Sep 16, 2021 at 8:58am   •  0 likes

Then the problem is with the content from the accessKey. You should print out the message id and then read the message to see its status.

var endpoint = '/restapi/v1.0/account/~/extension/~/message-store/[messageId]'
on Sep 16, 2021 at 9:00am   •  0 likes

I can't read the message status or the Id, because it fails at this line:

var resp = await ringCentral.Restapi().Account().Extension().Sms().Post(parameters);

It doesn't throw an exception. It just stops VS 2019 debugging. It doesn't even go to the next break point, nor does it hit the break point in the catch block.

How is it the problem with the accesskey when it won't even send when I put it like this:

var parameters = new CreateSMSMessage
                {
                    from = new MessageStoreCallerInfoRequest { phoneNumber = fromNumber },
                    to = new MessageStoreCallerInfoRequest[] { new MessageStoreCallerInfoRequest { phoneNumber = phone} },
                    text = "Hi"
                };
on Sep 16, 2021 at 11:15am   •  0 likes

You said it worked when you sent "Hello from C#" and did not work with the access key and bit.ly link. And now you said it does not work with "Hi".

You code or environment got corrupted some how. This works fine for me. It just failed sending if the link is a bit.ly shortened link, but no crash or whatsoever.

var parameters = new CreateSMSMessage();
                parameters.from = new MessageStoreCallerInfoRequest { phoneNumber = fromNumber };
                parameters.to = new MessageStoreCallerInfoRequest[] { new MessageStoreCallerInfoRequest { phoneNumber = RECIPIENT } };
                var access_key = "p-fc6844699aa82f6d4e1c23bb2-2";
                parameters.text = $"To see your results use access key - Access Key: {access_key} - https://google.com/whatever"; 
                var resp = await rcsdk.Restapi().Account().Extension().Sms().Post(parameters);
                Console.WriteLine("SMS sent. Message status: " + resp.messageStatus);
                Console.WriteLine("SMS sent. Message id: " + resp.id);



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

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us