Knowing how to send raw JSON data to an API End-Point is very important for a Junior Software Developer. This will save a lot of time when working on projects. Postman is an application an API Software Developer uses to test the functionality of an End-Point, hence, knowing how to utilize this tool adds value to your skillset needed to thrive in Software Development.
[Scenerial] You might find yourself in a situation where the Payload you are suppling to the Web API End-Point is always null. In this case, check if:
1. The object you are sending to the API is in a valid object type expected e.g.
{
"PropertyName": "Value",
"PropertyName": "Value",
"PropertyName": "Value",
}
//Wrong Way: This might give you problems
"ObjectName": {
"PropertyName": "Value",
"PropertyName": "Value",
"PropertyName": "Value",
}
2. Make sure that, you are not prefixing the object with a name, the API parameter from the body would not need an object to be named. It would accept whatever payload it is being supplied as long it is in a valid state.
Problems: Sometimes, if you are working on an old API technology where the function retrieves data from a body as well as from the URL. Knowing how to debug (step in and out of the debugger ) or send data in the right format to the Server-Side will help you move faster on a project.
[Tip] Try to know HTTP Verbs e.g. HttpPut, HttpPost, and HttpGet. Understand why these (among others) are used and their responses.
//Accepts HttpGet as well as HttpPut
[HttpGet,HttpPut]
public functionName([fromUri] string param1, [FromBody] Obeject param2){
}
When a Web API function does not accept the incoming object, chances are that an incoming object is not valid e.g. When the function is expecting an object of a Car that has properties such as,
Door, Tyers, and Color, the incoming object should contain all these properties. This can be argued that the newer API versions might not require all properties to be provided in an incoming object.