Hi,
I'm a veteran developer, who, through necessity, has returned to "the tools" after 20 years in IT management.
I'm currently developing a small application in Visual Basic (Visual Studio 2013) that converts very large .CSV files into JSON format and sends the data (customer info)to a 3rd party via their API.
I've written the fairly simple UI and the code to do the conversion to JSON and that all works fine, but I'm having no luck with connectivity to the 3rd party API.
I've tested the JSON code via a test driver on their portal back can't even get an error code back when I try it through VB.
At this stage, all I'm trying to do is login inti the API (using creds provided by the 3rd party) and get a Bearer Token in return.
Any help welcome!
Paul
What I have tried:
This is the code I'm using:
The parameters are:
uri = endpoint URL (as URI class)
jsonDataBytes = JSON format user creds encoded in UTF8
contentType = "application/json"
method = "POST"
It fails at
Using responseStream = request.GetResponse.GetResponseStream
With the error message "The request was aborted: Could not create SSL/TLS secure channel"
Private Function SendRequest(uri As Uri, jsonDataBytes As Byte(), contentType As String, method As String) As String
Dim response As String = ""
Dim request As WebRequest
request = WebRequest.Create(uri)
request.ContentLength = jsonDataBytes.Length
request.ContentType = contentType
request.Method = method
Try
Using requestStream = request.GetRequestStream
requestStream.Write(jsonDataBytes, 0, jsonDataBytes.Length)
requestStream.Close()
Using responseStream = request.GetResponse.GetResponseStream
Using reader As New StreamReader(responseStream)
response = reader.ReadToEnd()
End Using
End Using
End Using
Catch ex As Exception
AddLogEntry("ERROR! - " & ex.Message)
End Try
Return response
End Function