Формат JSON, который я пытаюсь достичь. {CardNumber: "4444333322221111", ExpiryMonth: 9, ExpiryYear: 2022, CardHolder: "Mr Test Card", CVN: "123", Клиент: {Код: "ABC123"}}
request = System.Net.HttpWebRequest.Create("https://api.test.payadvantage.com.au/v3/credit_cards")
request.Method = "POST"
request.Headers.Add("Authorization", "Bearer " + accesstoken)
request.ContentType = "application/x-www-form-urlencoded"
request.MediaType="application/json"
request.KeepAlive = True
request.ContinueTimeout = 10000
request.Host = "api.test.payadvantage.com.au"
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
outgoingQueryString = HttpUtility.ParseQueryString(String.Empty)
Dim outgoingSubQuery As NameValueCollection = HttpUtility.ParseQueryString(String.Empty)
Dim CustomerCode = "{ Code: '"& PayAdvantageIDStr &"' }"
outgoingQueryString.Add("CardNumber", NewCreditCardNumber)
outgoingQueryString.Add("ExpiryMonth", NewCCExpiryMonth)
outgoingQueryString.Add("ExpiryYear", NewCCExpiryYear)
outgoingQueryString.Add("CardHolder", NewCreditCardName)
outgoingQueryString.Add("CVN", NewCVC)
outgoingQueryString.Add("Customer", CustomerCode )
postBytes = New UTF8Encoding().GetBytes(outgoingQueryString.ToString())
Try
Dim newStream As Stream = request.GetRequestStream()
newStream.Write(postBytes, 0, postBytes.Length)
Catch ex As Exception
Dim MessageInput as string = ex.Message
Dim MessageOutput as String = Regex.Replace(MessageInput, "'", " ")
tblBillingAccount.GetControl(Of MTTextBox)("ISOScope").Value = tblBillingAccount.GetControl(Of MTTextBox)("ISOScope").Value + "CreditCard Fail" + MessageOutput
End try