Sending Post Parameters with Postman Doesn't Work, But Sending Get Parameters Does

Sending POST parameters with Postman doesn't work, but sending GET parameters does

I was setting the url in Postman to be http:// but Apache was redirecting to https:// and somehow the POST variables were being dropped along the way.

After I changed it to https://, the POST variables worked properly.

See also: https://stackoverflow.com/a/28461500/704803

POSTMAN not sending anything in the body in POST requests

The syntax of your body looks like JSON, yet you've specified the type of the body as "raw text". This will set the Content-type header of your request to "text/plain", which is probably causing your backend to be unable to actually read the body (because it expects a JSON object).

Simply switch from "Text" to "JSON", wrap your current body in curly braces (so that you're actually sending a single JSON object with a data property set) and try sending the request again. The content-type header will be correctly set to "application/json" this time and your backend will read the data successfully.

POST request in Postman doesn't work when adding query params

The problem is that your backend controller expects the account_id parameter in the path and you are providing it in the query string. To make it work, change the end of the URL to api/profile/:account_id in Postman, removing the query string. Also, this page shows how to set URL parameters on Postman: https://learning.getpostman.com/docs/postman/sending_api_requests/requests/

GET parameters work in the URL but not as Body in Postman

API is function binded to particular web uri, and every function defines it arguments type and place to accept input ( body or header param or path param.. etc)

So you just cannot pass parameters in request body as json, if the calling API is expected to take input as query params.

How to send parameters to any API (as body or as query params) are defined by API developer, If it is publicly exposed API, then there will be documentation defined API request and response.

Edited ( to add more information based on comment)

Behaviour of http methods are defined in RFC documents and these documents are updated time to time with new features or bug fixes.

The API can be written by developer using older version of HTTP server or client, that doesn't allow certain features.

Whereas postman as a tool wants to keep it ahead of race, so it has added new features so everyone who is using either old or new can use.

Why postman POST method do not provide params in `json` format?

If you want to send it as JSON, change from x-www-form-urlencoded to raw and you should see a drop down for Text, JSON, HTML. You can then select JSON

get request to accepts params in postman, currently sends a unsupported media type error

You can have method parameters bound to query parameters by using the [FromQuery] Attribute.

In your case, it should look something like this:

public async Task<IActionResult> getRentReason([FromQuery] int rentreasonId)

which will enable you to use <your controller path>/rentReason?rentreasonId=40


However, I'd recommend to use route parameters for this:

[HttpGet("/your/api/route/rentreason/{rentreasonId}")]
public async Task<IActionResult> getRentReason([FromRoute] int rentreasonId)

Which will get you something like <authority>/your/api/route/rentreason/40.

For reference: FromRouteAttribute

Post request from postman seems to not be sending any json data

I have figured out the answer to my issue. In the "Headers" I was missing the "Content-type - application/json". After adding this is seems to work.

Sample Image

Sending GET request parameters in body

Older versions of Postman didn't allow you to send body data with get request.

Yet, if your server receives data as URL parameters you won't be able just to change the way of sending them and include them to the body (server won't accept them).

So if the length of parameters is indeed so big and the server indeed can receive the same data from body instead of from parameters then the Postman is just not the tool that you can use (maybe cURL is for you).

If your server allows to send data only as URL parameters and they are so long (more then 2000 chars What is the maximum length of a URL in different browsers?) then I think you have no chances to test this API.

UPDATE: new Version 7.20.1 now allows to send Body with GET request



Related Topics



Leave a reply



Submit