vb.netinfobipinfobip-api

Compiler Error Message: BC30002: Type 'RestClient' is not defined


I am trying to integrate a bulk SMS API. After following their sample code, I am getting Compiler Error Message: BC30002: Type 'RestClient' is not defined.

The code is as below

<%@ Page Language="VB" Debug = "true" ContentType="text/html"       ResponseEncoding="iso-8859-1" %>
<%@ Import Namespace="System.Data.SqlClient"%>
<%@ Import Namespace="System.net.mail"%>
<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.Net.http" %>
<%@ Import Namespace="System.text" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="microsoft.http" %>
<%@ Import namespace="System.Web.Script.Serialization" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="Restclient" %>

<SCRIPT language="vb" runat="server">


Sub Page_load(S as Object,E as EventArgs)


Dim client = New RestClient("https://api.infobip.com/sms/1/text/single")

' Dim byt As Byte() = System.Text.Encoding.UTF8.GetBytes(strOriginal)  
'
'    ' convert the byte array to a Base64 string
'
'    strModified = Convert.ToBase64String(byt)

Dim request = New RestRequest(Method.POST)
request.AddHeader("accept", "application/json")
request.AddHeader("content-type", "application/json")
request.AddHeader("authorization", "Basic   ctrtre2hvbGFkcm0xOmNoYW5nZW1lMUE=")'base64 of usename and password
request.AddParameter("application/json", "{""from"":""SMS"", ""to"":[  ""4356653443"",""2348056355307""],""text"":""Test SMS.""}", ParameterType.RequestBody)

Dim response As IRestResponse = client.Execute(request)
response.Write(response)




end sub
</SCRIPT>

Please help me.


Solution

  • Since you've mentioned RestClient i'm going to assume you are trying to use the RestSharp Project. You'll need to add the runtime binary as a reference.

    An easier option would be to add it via Nuget.

    UPDATE FOR ADD REFERENCE

    In Solution Explorer, double-click the My Project node for the project.

    In the Project Designer, click the References tab.

    Click the Add button to open the Add Reference dialog box.

    In the Add Reference dialog box, look for "Browse" then locate the dll on the file system where you store it or navigate to the bin if you have it there.