Register User Device - ASP.Net C#

Source Code Option 1: System.Net

  
 

using System.Net;



   public static string RegisterUserDeviceToken(string message, string destinationurl, string devicetoken, string platform, string UserID, string tag)
   {
       string strResponse = "0";
       string apikey = "YOUR-API-KEY";


       string URI = "https://send.pushnotificationapi.com/v1/device/add";
       string myParameters = "api_key=" + apikey + "&user_id=" + UserID + "&device_token=" + devicetoken + "&platform=" + platform + "&tag=" + tag;



       using (WebClient wc = new WebClient())
       {
           wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
           strResponse = wc.UploadString(URI, myParameters);


       }

       return strResponse;
   }
 

Source Code Option 2: RestSharp

  
 
                           
var client = new RestClient("https://send.pushnotificationapi.com/v1/device/add");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/x-www-form-urlencoded");
request.AddParameter("application/x-www-form-urlencoded", "api_key=YOUR-API-KEY&device_token=YOUR-DEVICE-TOKEN&platform=YOUR-PLATFORM&user_id=OPTIONAL-USER-ID&tag=OPTIONAL-TAG", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);