![]() ![]() To use this option, select binary and then click on Select File to browse any file from your system. Binaryīinary is used to send the data in a different format. In the above examples, we already discussed the raw. Here the body data will be presented in the form of a stream of bits. This is a very useful option while sending the body to the POST method. The only difference between both of them is that, when you sent the data via x-Raw Here, the key is the name of the entry, and value is the value of the entry you are sending. ![]() To send these details, write them as key-value pairs. Such as the information you enter while filling out a form. Select the POST request method, and go to Body option where we have different options for sending data:įorm-data sends the form's data. Since now, you know that we need to send the body data with requests whenever you need to add or update structured data. Here, "Operation completed successfully" means your entry has been created successfully, and your POST request has done successfully. Let's enter the different value and check the response status: The error "User already exists" means the data already exist in the database. Here the status code is 200 OK this means the server approved the request, and we received a positive response. Just change the attribute value to the required value, like the below example:įinally, press Send and see the response body and response status. Here is one simple example:Ĭopy and paste the above example to your postman request Body. In my example, server expects a json body that contains new user information. This is done because we need to send the request in the appropriate format that the server expects. Now in the Body tab, select raw and select JSON as the format type from the drop-down menu, as shown in the image below. So, we are required to add the information with the correct format within the request body.Īdding a Request body to the Post request- For this, select the Body tab. And from the response body, 'Invalid post data' means the entered post data is not valid. Here, 400 Bad Request, as shown in the image above, indicates that the request and server parameters are not found matched to get a response. ![]() Post Request without Bodyįirst, change the type of method from GET to POST and click on the Send button. Now let's try to change the type of method and see if we will get the right response. This means we selected the incorrect method type. And in the Pretty tab also you can see the fault error. It means we are requested for an endpoint with the wrong method. See the HTTP status code, and you will get the "405 Method Not Allowed" error code. Then select the GET method from the drop-down list. Here, we have one API which is used to register a new customer:Įnter the URL in the postman endpoint bar, and press Send. Let's first check with the GET request for a POST endpoint. When an endpoint states that it should be called using the POST http verb, then for calling the endpoint, only the POST HTTP Verb is required. In Postman, every endpoint of REST API is associated with its HTTP verb. There is no restriction of data length in POST requests.POST requests are not left in the history of browsers.POST requests will not take the cookies. ![]() The POST request is a fundamental method, and this method is mostly used when a user wants to send some sensitive data to the server like to send a form or some confidential data. The server creates a new account with the same information and that account, and the information is added permanently on the Facebook server. One of the best examples of using POST request is the login page of Facebook or the login page of other sites you send your personal information such as the password to the server. In general, when we submit a POST request, we expect to have some change on the server, such as updating, removing or inserting. We use this method when additional information needs to be sent to the server inside the body of the request. ![]()
0 Comments
Leave a Reply. |