REST - HttpClient - Server, C#, Practical example

Markus Freitag 3,791 Reputation points
2023-09-08T16:21:08.2+00:00

Hello,

The idea would be to send a JSON response on GET and on POST.

With GET I query all entries. With PUT I add entries.

Both return a response in JSON.

Sounds simple, who has experience certainly easy to solve. Can someone show me?

// Response for Get and Put
public class ResponseStandard
{
	[JsonProperty("status")]
	public int Status { get; set; }

	[JsonProperty("error")]
	public int Error { get; set; }

	[JsonProperty("msg")]
	public string Msg { get; set; }
}

// Process 
public class Product
{
	[JsonProperty("name")]
	public string Name { get; set; }

	[JsonProperty("price")]
	public double Price { get; set; }

	[JsonProperty("quantity")]
	public int Quantity { get; set; }
}

// My working object.
  List<Product> ListProduct = new List<Product>();

// ** On Client desktop C# App
   Add, Delete, Edit is important

Can I transfer the application to another PC and test it, without a development environment? If so, what would I need to do? Do you have an instruction?

Developer technologies | Windows Forms
Developer technologies | ASP.NET | Other
Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.