Testing the web API
The best tools to test a web API are Fiddler (https://www.telerik.com/fiddler) or Postman (https://www.postman.com/). I prefer Postman because I find it easier to use. You can use either tool, but in these demos, we will use Postman:
- In Postman, create a new request. Enter the API URL, which is https://localhost:5001/api/persons (the port of the URL might vary), into the
address
field, and then, add a header with theAccept
key and theapplication/json
value. - After clicking Send, you will see the JSON result in the response body, as shown in the following screenshot:
Here, you can see the autogenerated values. The GenFu
object puts the data into the person's properties, based on the property type and the property name: real first names and real last names, as well as real cities and properly formatted phone numbers.
- Next, let's test the XML output...