1

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.

msmolcic
  • 6,407
  • 8
  • 32
  • 56
Pope
  • 55
  • 2
  • 8

1 Answers1

0

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.

scartag
  • 17,548
  • 3
  • 48
  • 52
  • Scartag, can you please give example or reflect it on the code – Pope Jan 07 '16 at 07:01
  • @Pope I can't reflect a binary reference in the code. You'll need to look for the dll check this url and unzip the most recent version and put the dll in your bin folder https://github.com/restsharp/RestSharp/downloads – scartag Jan 07 '16 at 16:27
  • Scartag, Thank you for your response. I have unzipped the library into my bin folder, but i am now getting "CS0246: The type or namespace name 'RestClient' could not be found (are you missing a using directive or an assembly reference?)" – Pope Jan 08 '16 at 18:03
  • – Pope Jan 08 '16 at 18:08
  • Scartag, Thank you. <%@ Import Namespace="RestSharp" %> worked – Pope Jan 11 '16 at 17:22
  • @Pope there should be a grey colored tick mark by the side of the answer. Close to where you have the upvote and downvote buttons. You can click it to accept it as the correct answer. – scartag Jan 13 '16 at 10:14
  • please i need to change the "sender" and "238045366373" to varaible strings such that that can assume different values ata different times request.AddParameter("application/json", "{""messages"":[{""from"":""sender"",""to"":[""238045366373""],""text"":""May the God be with you Jolaoluwa!""}]}", ParameterType.RequestBody) Please help – Pope Jan 13 '16 at 11:12
  • @ scarTag please i need to change the "sender" and "238045366373" to varaible strings such that that can assume different values ata different times request.AddParameter("application/json", "{""messages"":[{""from"":""sender"",""to"":[""238045366373""],""text"":""May the God be with you Jolaoluwa!""}]}", ParameterType.RequestBody), The error message i get is " Compiler Error Message: BC30516: Overload resolution failed because no accessible 'AddParameter' accepts this number of arguments." Please help – Pope Jan 13 '16 at 11:16
  • http://stackoverflow.com/questions/34764688/how-to-substitute-fixed-value-t-to-variable-name-into-request-addparameter-stat – Pope Jan 13 '16 at 11:26