I have made a test project that will make API REST with the following characteristics:
- ASP.NET web application (Visual basic)
- .NET Framework 4.7.2
- When creating the application, I choose: Web API (No HTTPS)
- Once created:
- Add new element "ADO.NET Entity Data Model"
- Code First from Database
- I configure the connection and add all the tables
At this point I've created a test handler for one of the tables, which allows me to connect from Postman (I've tested it a bit and it works fine) to:
http://localhost:54541/api/users
So far, I think all good.
My problem comes now. The idea of this project (which is going to be my PFG) is to act as a service, and apart from creating a second project type "Windows Forms Application" that acts as a client.
To do the latter, I've tried creating a Windows Forms application and adding a data source of type "Service", but I can't "see" the other project.
How should I do this?
I've been doing internet searches about this, but what little I find doesn't quite help me. Also, most of the things are in C# and I'm not clear.
I hope someone can give me a hand.
Although I feel stupid and tempted to just delete my question, I thought that maybe one day another newbie like me goes through the same situation and maybe this will help you.
The answer is that you don't need to add any data sources. The two applications will not communicate as a Windows Forms application would communicate with a database, but through URLs and the use of http verbs (Get, Put, Post and Delete)
As an example, I have made (in the client application) a User class:
On the other hand, in the file Form1.vb I create a test method that allows me to retrieve the users:
This is just a test. Ideally, we will separate the GetHttp method and take it to another class in which we implement the methods for Get, Get/id, Post, Put and Delete, as well as any others that we may need.