Hi @Claude Larocque ,Welcome to Q&A.
You can use httpclient and System.Text.Json.
Here is a winform example I wrote (.Net Framework 4.8):
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Windows.Forms;
namespace WindowsFormsApp2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private async void button1_Click(object sender, EventArgs e)
{
try
{
string url = "http://example.com/api/v1/resource";
HttpClient client = new HttpClient();
var requestData = new { key = "value" };
string json = JsonSerializer.Serialize(requestData);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync(url, content);
string responseContent = await response.Content.ReadAsStringAsync();
MessageBox.Show(responseContent);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
There may be a lack of system.memory during operation. (Manually add it into the project)
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
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.