I am developing an app which requires SMS gateway service. Our company uses Plivo service. I followed along the sample code. When I tried to build solution I received two errors:
Error 1:The type 'RestSharp.IRestResponse'1<T0>' is defined in an assembly that is not referenced. You must add a reference to assembly 'RestSharp, Version=105.1.0.0, Culture=neutral, PublicKeyToken=null'
Error 2:Cannot implicitly convert type 'RestSharp.IRestResponse'1<Plivo.API.MessageResponse>' to 'RestSharp.IRestResponse<Plivo.API.MessageResponse>'
I don't get the reasons for these errors since I installed Plivo and RestSharp API's through NuGet and can see the dll's in Solution Explorer.
The second error is even more confusing to me because of the strange type 'RestSharp.IRestResponse'1
.
If anyone could advise me on this issues I'd be very grateful.
My source code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RestSharp;
using Plivo.API;
using System.Reflection;
namespace SMSGatewayTest
{
class Program
{
static void Main(string[] args)
{
string auth_id = "XXX"; // obtained from Plivo account dashboard
string auth_token = "YYY"; // obtained from Plivo account dashboard
RestAPI plivo = new RestAPI(auth_id, auth_token);
IRestResponse<MessageResponse> resp = plivo.send_message(new Dictionary<string, string>()
{
{ "src", "37061549145" },
{ "dst", "37068824525" },
{ "text", "Hi, text from Plivo." },
});
if (resp.Data != null)
{
PropertyInfo[] proplist = resp.Data.GetType().GetProperties();
foreach (PropertyInfo property in proplist)
Console.WriteLine("{0}: {1}", property.Name, property.GetValue(resp.Data, null));
}
else
{
Console.WriteLine(resp.ErrorMessage);
}
}
}
}
P.S. If I missed something while writing a question, please, ask for it - it's my first experience with SMS-gateway