Hi @StewartBW ,
Check the following steps.
- Create an instance of
HttpClient
to manage the HTTP communication. - Use
StringContent
class to prepare the request body with the necessary form URL-encoded parameters (PrimaryUsername
andPrimaryPassword
). - Use
PostAsync
method to send the POST request to the specified URL. - Use the
XDocument
class to resolveBalance
andResultCode
from the responding XML.
Dim url As String = "https://ws.interfax.net/admin.asmx/GetAccountPPCardsBalance2"
Dim primaryUsername As String = "your_primary_username"
Dim primaryPassword As String = "your_primary_password"
Using client As New HttpClient()
Dim content As New StringContent($"PrimaryUsername={primaryUsername}&PrimaryPassword={primaryPassword}", Encoding.UTF8, "application/x-www-form-urlencoded")
Dim response As HttpResponseMessage = Await client.PostAsync(url, content)
response.EnsureSuccessStatusCode()
Dim responseContent As String = Await response.Content.ReadAsStringAsync()
Dim doc As XDocument = XDocument.Parse(responseContent)
Dim ns As XNamespace = "http://interfax.net/Admin"
Dim balance As Decimal = Decimal.Parse(doc.Root.Element(ns + "Balance").Value)
Dim resultCode As Integer = Integer.Parse(doc.Root.Element(ns + "ResultCode").Value)
End Using
Best Regards.
Jiachen Li
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.