Hi,
I have create rest api for get method and deployed in public server, when i call rest api using below code i will get error "The remote server returned an error: (403) Forbidden."
Dim wc As WebClient
wc = New WebClient
Try
Dim res As Boolean
wc.Headers.Add("x-api-key", "JKL4Or9GF0")
res = wc.DownloadString("http://localhost:56590/Home/ValidName?LastName=Vogel")
If res Then
End If
Catch ex As Exception
End Try
What I have tried:
I will tried with Chilkat dll for call that api, it works and i get return value, in that i set TSL as false, but that dll need to purchase,so i moved ordinary vb code, so in above code how to set tsl as false.
Below the code which is working with chilkat
Dim rest As New Chilkat.Rest
Dim success As Boolean
Dim bTls As Boolean = False
Dim port As Integer = 80
Dim bAutoReconnect As Boolean = True
success = rest.Connect("http://localhost:56590/", port, bTls, bAutoReconnect)
If (success <> True) Then
Exit Sub
End If
rest.AddHeader("x-api-key", "JKL4Or9GF0")
success = rest.FullRequestNoBodySb("GET", "http://localhost:56590/Home/ValidName?LastName=Vogel", sbResponseBody)
If (success <> True) Then
lblmsg1.Text = "2" & rest.LastErrorText
Exit Sub
End If
Dim respStatusCode As Integer = rest.ResponseStatusCode
If (respStatusCode >= 400) Then
lblmsg1.Text = "Response Status Code = " & respStatusCode
Exit Sub
End If
Dim jsonResponse As New Chilkat.JsonObject
jsonResponse.LoadSb(sbResponseBody)
Note: For security purpose i changed the url, is there any alternative vb code for call rest api instead of using chilkat ?
Regards,
Aravind