Skip to main content
The First Step
Mar 4, 2021 5:57 PM UTC
Solved

MMS C# Error

I'm following the tutorial at https://ringcentral-tutorials.github.io/sms-api-csharp-demo/?distinctId=201757107#3

Everything work fine when sending the Sms message but when I try the Mms example I get as compile error stating "Argument 2: cannot convert from 'RingCentral.Attachments[]' to 'RingCentral.RestRequestConfig'. The error is on line 56 of the above tutorial:

var resp = await rc.Restapi().Account().Extension().Sms().Post(parameters, attachments);

Anyone know the solution to this?

    PhongVu
    PhongVuAnswer
    Community Manager
    Mar 5, 2021 6:18 PM UTC

    The tutorial was created using the old .Net SDK.

    Using the current SDK, please modify the code as follows

    var parameters = new CreateMMSMessage();
    parameters.from = new MessageStoreCallerInfoRequest { phoneNumber = fromNumber };
    parameters.to = new MessageStoreCallerInfoRequest[] { new MessageStoreCallerInfoRequest { phoneNumber = RECIPIENT } };
    parameters.text = "Hello World from C#";
    var attachment = new Attachment { fileName = "test.jpg", contentType = "image/jpeg", bytes = File.ReadAllBytes("test.jpg") };
    parameters.attachments = new Attachment[] { attachment };
    var resp = await rc.Restapi().Account().Extension().Mms().Post(parameters);


    3 replies

    PhongVu
    Community Manager
    PhongVuAnswer
    Community Manager
    Mar 5, 2021 6:18 PM UTC

    The tutorial was created using the old .Net SDK.

    Using the current SDK, please modify the code as follows

    var parameters = new CreateMMSMessage();
    parameters.from = new MessageStoreCallerInfoRequest { phoneNumber = fromNumber };
    parameters.to = new MessageStoreCallerInfoRequest[] { new MessageStoreCallerInfoRequest { phoneNumber = RECIPIENT } };
    parameters.text = "Hello World from C#";
    var attachment = new Attachment { fileName = "test.jpg", contentType = "image/jpeg", bytes = File.ReadAllBytes("test.jpg") };
    parameters.attachments = new Attachment[] { attachment };
    var resp = await rc.Restapi().Account().Extension().Mms().Post(parameters);


    The First Step
    Mar 5, 2021 10:06 PM UTC

    Thank you, I will give that try :)

    The First Step
    Mar 5, 2021 10:25 PM UTC

    That did it, thank you so much