RuwanRatnayake-2754 avatar image
0 Votes"
RuwanRatnayake-2754 asked RoyLi-MSFT edited

How to get data from API

Private Function PostApiCall(txtV As String) As String
' Try
Dim endPoint As String = ""
'Contruct Json Request
Dim dictData As New Dictionary(Of String, Object)
dictData.Add("vehicle_number", txtV)

         Dim reqString() As Byte
         Dim resByte As Byte()
         Dim responseFromApi As String

         Dim client As WebClient = New WebClient()

     client.Headers("Content-type") = "application/json"
     client.Headers("Authorization") = "8Kn2o3yCJzjwGYvrBpii"
     client.Encoding = Encoding.UTF8
         Dim jsonReq = JsonConvert.SerializeObject(dictData, Formatting.Indented)
         reqString = Encoding.Default.GetBytes(jsonReq)

         resByte = client.UploadData(endPoint, "post", reqString)
         responseFromApi = Encoding.Default.GetString(resByte)
         Return responseFromApi
     'Catch ex As Exception
     '    Throw (ex)
     'End Try
 End Function

Showing Error -System.Net.WebException: 'The remote server returned an error: (405) Method Not Allowed.'

Please some one tell me how to handle this

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers