Upgrade from .NET SDK Legacy to v4.10.0 or Latest Version

Introduction

This is a major application update. Plivo recommends you always use the latest or an active version of our SDKs for guaranteed security, stability, and uptime. The active SDK versions are designed to handle intermittent and regional failures of API requests. In addition, they offer a host of security features, such as protection against DoS attacks and bot detection for suspicious user agents.

Deprecation notice: We’re deprecating Plivo .NET SDK legacy versions lower than v4.10.0 on January 31, 2022. If you use a deprecated version of our SDK after that date, your API requests and messaging may fail intermittently. Plivo will no longer provide bug fixes to these versions, and our support team may ask you to upgrade before debugging issues.

Migrate your applications

.NET version support

The Plivo .NET SDK supports .NET applications written in C# and Visual Basic that utilize the .NET Framework version 3.5 or higher or any .NET runtime supporting .NET Standard v1.4.

Use the command Update-Package Plivo -Version 4.10.0 to upgrade to the active version of the SDK, or Update-Package Plivo to upgrade to the latest version.

After you upgrade, you should check every program that depends on the SDK and make changes to the syntax for several kinds of operations. Here are examples of how coding differs between the deprecated legacy versions of the SDK and the latest active versions.

Import the SDK

Legacy Latest
using System;
using System.Collections.Generic;
using RestSharp;
using Plivo.API;
   
using System;
using System.Collections.Generic;
using Plivo;
   

Initialize

Legacy Latest
RestAPI plivo = new RestAPI("<auth_id>","<auth_token>");
   
var api = new PlivoApi("<auth_id>","<auth_token>");
   

Access resources

Legacy Latest
IRestResponse < MessageResponse > resp =
  plivo.send_message(new Dictionary < string, string > () {params});
   
var response = api.Message.Create(params);
   

Send a message

Legacy Latest
using System;
using System.Collections.Generic;
using System.Reflection;
using RestSharp;
using Plivo.API;
namespace Send_Sms
{
    class Program
    {
        static void Main(string[] args)
        {
            RestAPI plivo = new RestAPI("<auth_id>", "<auth_token>");
            IRestResponse<MessageResponse> resp = plivo.send_message(new Dictionary<string, string>()
            {
                { "src", "+12025551212" },
                { "dst", "+12025552323" },
                { "text", "Hello, this is a sample text" }, 
                { "url", "https://<yourdomain>.com/sms_status/"}
                 });
            Console.Write(resp.Content);
           Console.ReadLine();
        }
    }
}
   
using System;
using System.Collections.Generic;
using Plivo;

namespace PlivoExamples
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var api = new PlivoApi("<auth_id>","<auth_token>");
            var response = api.Message.Create(
                src: "+12025551212",
                dst: "+12025552323",
                text: "Hello, this is a sample text",
                url: "https://<yourdomain>.com/sms_status/"
                );
            Console.WriteLine(response);
        }
    }
}
   

Retrieve a message

Legacy Latest
using System;
using System.Collections.Generic;
using System.Reflection;
using RestSharp;
using Plivo.API;

namespace Get_Details
{
    class Program
    {
        static void Main(string[] args)
        {
            RestAPI plivo = new RestAPI("<auth_id>", "<auth_token>");
            IRestResponse<Message> resp = plivo.get_message(new Dictionary<string, string>()
            {
                { "record_id", "<your_message_uuid>" }
            });

            Console.Write(resp.Content);
    
            Console.ReadLine();
        }
    }
}
   
using System;
using Plivo;
using Plivo.Exception;

namespace PlivoExamples
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var api = new PlivoApi("<auth_id>","<auth_token>");
                var response = api.Message.Get(
                    messageUuid: "<your_message_uuid>"
                );
                Console.WriteLine(response);
        }
    }
}
   

List all messages

Legacy Latest
using System;
using System.Collections.Generic;
using System.Reflection;
using RestSharp;
using Plivo.API;

namespace GetAllDetails
{
    class Program
    {
        static void Main(string[] args)
        {
            RestAPI plivo = new RestAPI("<auth_id>","<auth_token>");
            IRestResponse<MessageList> resp = plivo.get_messages();

            Console.Write(resp.Content);
     
            IRestResponse<MessageList> response = plivo.get_messages(new Dictionary<string, string>()
            {
                { "limit", "10" },
                { "offset", "0" }
            });
    
            Console.WriteLine(response.Content);
    
            Console.ReadLine();
        }
    }
}
   
using System;
using System.Collections.Generic;
using Plivo;

namespace PlivoExamples
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var api = new PlivoApi("<auth_id>","<auth_token>");

                var response = api.Message.List(
                    limit:10,
                    offset:0
                );
                Console.WriteLine(response);
        }
    }
}