Making A Post Request With Data In - Shakti Singh Cheema
Có thể bạn quan tâm
Making a post request with data in vb.net
One of the major challenge is to make a post request to an api with data.
Most important for this is to serialize the post data in proper format.
Bellow is the basic syntax to create a api post request and getting the response.
Dim postdata As New JObject postdata.Add("service_id", "value 1") postdata.Add("template_id", "Value 2") postdata.Add("user_id", "Value 3") 'postdata contains data which will be posted with the request Dim finalString as String = postdata.ToString Dim httpWebRequest = CType(WebRequest.Create("Api address Here"), HttpWebRequest) httpWebRequest.ContentType = "application/json" httpWebRequest.Method = "POST" Using streamWriter = New StreamWriter(httpWebRequest.GetRequestStream()) streamWriter.Write(finalString) End Using Dim httpResponse = CType(httpWebRequest.GetResponse(), HttpWebResponse) Using streamReader = New StreamReader(httpResponse.GetResponseStream()) Dim responseText as String = streamReader.ReadToEnd() 'responseText contains the response received by the request End UsingHere the data format is:
{ service_id: 'YOUR_SERVICE_ID', template_id: 'YOUR_TEMPLATE_ID', user_id: 'YOUR_USER_ID' }And response is in JSON or text string.
For using Jobject you need to have newtonsoft DLL.
You can install newtonsoft you can use Nuget or download from the website here
Từ khóa » Visual Basic Send Post Request
-
Visual Basic 2010 HTTP POST Request - - Stack Overflow
-
Http Post And Response From Server - CodeProject
-
VB .NET Http Post Request Program Example
-
How To: Send Data By Using The WebRequest Class - .NET Framework
-
HttpClient Class (System.Net.Http) | Microsoft Docs
-
Post Json On Url Http Web Request With Vbnet
-
Thread: Send A POST Request Of JSON Content-type - VBForums
-
Thread: Simple HTTP Request - VBForums
-
C# GET/POST Request - ZetCode
-
[VB.NET] Hướng Dẫn Sử Dụng Http Request Post Lấy Facebook ID
-
Http Post Request In Vb.Net - ADocLib
-
JSON HTTP POST Request In Visual Basic .NET · GitHub
-
Http Post Example - CodeNotes - Visual Basic Planet
-
VB.NET || How To Send, Post & Process A REST API Web Request ...