V
valliammai26
Guest
Hi,
I am using visual basic 2003 windows application. I have one button, where when I click the button it should open api webpage using the url and send the parameters. I have written the code in 2017 visual basic with no issues. But I cant write the same code in 2003 because Newston.Json and system.http is not available. I cant do the serialization. Can someone help me? Below is my code in 2017 vb. The bolded part is where i get the error in 2003
Imports Newtonsoft.Json
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Net.Http
Imports System.Text
Imports System.Threading.Tasks
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Public Class test2
Inherits System.Web.UI.Page
Private Async Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim paras As PointPara = New PointPara
paras.membercode = "701111071111"
paras.Amount = "20"
Dim Result = Await DeductBalance(paras)
End Sub
Public Class PointPara
Private _membercode As String
Private _Amount As String
Public Property membercode As String
Get
Return _membercode
End Get
Set(VALUE As String)
_membercode = VALUE
End Set
End Property
Public Property Amount As String
Get
Return _Amount
End Get
Set(value As String)
_Amount = value
End Set
End Property
End Class
Public Async Function DeductBalance(ByVal para As PointPara) As Task(Of String)
Dim AgentPostURL As String = "http://themeparkv1.azurewebsites.net/themepark/api/Point/CreditDeduct"
Dim client As HttpClient = New HttpClient
'= await GetClient( PostURL, ParentNRIC);
Dim jsonstringSend = JsonConvert.SerializeObject(para)
Dim response = Await client.PostAsync(AgentPostURL, New StringContent(jsonstringSend, Encoding.UTF8, "application/json"))
Return Await response.Content.ReadAsStringAsync
End Function
End Class
Continue reading...
I am using visual basic 2003 windows application. I have one button, where when I click the button it should open api webpage using the url and send the parameters. I have written the code in 2017 visual basic with no issues. But I cant write the same code in 2003 because Newston.Json and system.http is not available. I cant do the serialization. Can someone help me? Below is my code in 2017 vb. The bolded part is where i get the error in 2003
Imports Newtonsoft.Json
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Net.Http
Imports System.Text
Imports System.Threading.Tasks
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Public Class test2
Inherits System.Web.UI.Page
Private Async Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim paras As PointPara = New PointPara
paras.membercode = "701111071111"
paras.Amount = "20"
Dim Result = Await DeductBalance(paras)
End Sub
Public Class PointPara
Private _membercode As String
Private _Amount As String
Public Property membercode As String
Get
Return _membercode
End Get
Set(VALUE As String)
_membercode = VALUE
End Set
End Property
Public Property Amount As String
Get
Return _Amount
End Get
Set(value As String)
_Amount = value
End Set
End Property
End Class
Public Async Function DeductBalance(ByVal para As PointPara) As Task(Of String)
Dim AgentPostURL As String = "http://themeparkv1.azurewebsites.net/themepark/api/Point/CreditDeduct"
Dim client As HttpClient = New HttpClient
'= await GetClient( PostURL, ParentNRIC);
Dim jsonstringSend = JsonConvert.SerializeObject(para)
Dim response = Await client.PostAsync(AgentPostURL, New StringContent(jsonstringSend, Encoding.UTF8, "application/json"))
Return Await response.Content.ReadAsStringAsync
End Function
End Class
Continue reading...