Click here to Skip to main content
15,891,943 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("https://api.test.payadvantage.com.au/v3/token")
request.Method = "POST"
request.ContentType = "application/x-www-form-urlencoded"
request.ContentLength = 94
request.KeepAlive = True
request.ContinueTimeout = 10000
request.Host = "api.test.payadvantage.com.au"
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
Dim outgoingQueryString As NameValueCollection = HttpUtility.ParseQueryString(String.Empty)
outgoingQueryString.Add("grant_type", "password")
outgoingQueryString.Add("username", username)
outgoingQueryString.Add("password", password)
 Dim postBytes As Byte() = New UTF8Encoding().GetBytes(outgoingQueryString.ToString())


Try
    Using requestStream = request.GetRequestStream()
      requestStream.Write(postBytes, 0, postBytes.Length)
End Using
Catch ex As Exception

    Dim MessageInput as string = ex.Message
    Dim MessageOutput as String = Regex.Replace(MessageInput, "'", " ")
    tblBillingAccount.GetControl(Of MTTextBox)("ISOScope").Value = "Auth Fail " + MessageOutput
End try

Try
     Using response = CType(request.GetResponse(), HttpWebResponse)
     accessToken = response.StatusDescription
End Using
Catch ex As Exception
    Dim MessageInput as string = ex.Message
    Dim MessageOutput as String = Regex.Replace(MessageInput, "'", " ")
    tblBillingAccount.GetControl(Of MTTextBox)("ISONotApplicable").Value = "Auth Fail " + MessageOutput

End try


What I have tried:

Some of the parameters are included from Pay Advantage Documentation. ie keep alive and content length. I have tried multiple security protocols and this is the only one that does not return an error.

Urgently need some help to get this project over the line. Thanks in advance.
Posted
Updated 15-Mar-20 12:26pm
Comments
MadMyche 15-Mar-20 10:36am    
And which line is generating that error?

1 solution

Using requestStream = request.GetRequestStream()
 
Share this answer
 
Comments
Richard Deeming 17-Mar-20 8:11am    
If you want to reply to a comment, click the "Reply" button next to the comment.

Do not post your reply as a "solution" to your question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900