Forum Discussion
- robertsommer621New Contributor
- GET Read or retrieve data
- POST Add new data
- PUT Update data that already exists
- DELETE Remove data
I need to test this via a C# WPF desktop application. For this I need a SERVER. How can I achieve this quickly and easily?
There is so much information that is difficult for a beginner to understand.static async Task Main(string[] args) { // Your XML string string xmlData = @"<Request><Data>Hello, REST Interface!</Data></Request>"; // The URL to send the POST request to (update with your local server URL) string url = "https://localhost:5044/api/MyHomeController"; // Create a new HttpClient instance using (HttpClient client = new HttpClient()) { // Set the content type to XML HttpContent content = new StringContent(xmlData, Encoding.UTF8, "application/xml"); // Send the POST request HttpResponseMessage response = await client.PostAsync(url, content); // Ensure the response was successful, or throw an exception response.EnsureSuccessStatusCode(); // Read the response content string responseContent = await response.Content.ReadAsStringAsync(); } }
Related Content
- 2 years ago
- 2 years ago
- 3 years ago
- 11 months ago