Skip to main content
Answer

MMS C# Error

  • March 4, 2021
  • 3 replies
  • 374 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?

Best answer by PhongVu

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
Forum|alt.badge.img
  • Community Manager
  • Answer
  • March 5, 2021

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



  • Author
  • New Participant
  • March 5, 2021

Thank you, I will give that try :)


  • Author
  • New Participant
  • March 5, 2021

That did it, thank you so much