Skip to main content
The First Step
September 16, 2021
Solved

App stops after SMS API Call

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.

    info-25Answer
    The First Step
    September 16, 2021

    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.

    3 replies

    PhongVu
    Community Manager
    Community Manager
    September 16, 2021

    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.

    info-25The First StepAuthor
    The First Step
    September 16, 2021

    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

    info-25The First StepAuthorAnswer
    The First Step
    September 16, 2021

    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.