Solved

MMS C# Error

  • 4 March 2021
  • 3 replies
  • 353 views

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?

icon

Best answer by Phong1426275020 5 March 2021, 19:18

View original

3 replies

Userlevel 1

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);


Thank you, I will give that try :)

That did it, thank you so much

Reply