Mounarajan
Mounarajan

Reputation: 1437

Request working in curl but not in postman

This request working with curl

curl 'http://www.express.com/browse/gadgets/store-change-location-more.jsp?changelocation=true&catelogRefId=75116576' -H 'Cookie: JSESSIONID=6D26018EFF8B54EC4022299B2AC7B184.cmhlpecomecm02w2;' --compressed

But the same request not working in post man

Post man request

Request Type : GET

URL : http://www.express.com/browse/gadgets/store-change-location-more.jsp?changelocation=true&catelogRefId=75116576

Headers:

Cookie: JSESSIONID=6D26018EFF8B54EC4022299B2AC7B184.cmhlpecomecm02w2;

How to make request work with post man too?

Upvotes: 26

Views: 39444

Answers (13)

starwed
starwed

Reputation: 2607

One case not discussed yet: curl will attempt to use HTTP 2 where available, while Postman only supports HTTP 1.1.

I ran into an api that returned a 500 when the connection used 1.1, which meant the calls were working with curl but failing with postman. When I passed the --http1.1 flag to curl, it got the same response as Postman.

More generally, running curl in verbose mode (with the -v flag) can help you figure out what could be different between the two requests.

Upvotes: 2

Blundell
Blundell

Reputation: 76564

I had an even sillyer issue!

The cURL created by chrome worked, but when I imported it into Postman it didn't.

Only I'd forgot to change the method type in postman to POST instead of GET 😬

Upvotes: 0

Adam Johns
Adam Johns

Reputation: 36373

I had to make sure all the hidden auto-generated headers in postman were checked/enabled. I had initially disabled them which was causing this issue for me.

Upvotes: 6

Kirill Yunussov
Kirill Yunussov

Reputation: 2313

My use case was that I was trying to get oauth2 token, and had the client-id and client-secret as key-value pairs in the x-www-form-urlencoded section of the request body.

I kept getting an error saying

{
     "fault": {
         "faultstring":"Invalid client identifier {0}",
         "detail": {"errorcode":"oauth.v2.InvalidClientIdentifier"}
      }
}

The solution was to put credentials into the raw section of the request body instead, as follows:

grant_type=client_credentials&client_id=some-client-id&client_secret=some-client-secret

Got the token after that.

Upvotes: 0

Krzysztof GawryÅ›
Krzysztof GawryÅ›

Reputation: 51

In my case it was a newline at the end of url in Postman. There actually WAS a newline indicator in url bar, but it looked more like a dirt on the monitor so I missed it. Also the curl WAS in fact generated correctly, but I initially thought it is some issue regarding single or double quotas on Windows so I was changing them and also deleting the newline happily without thinking to make it work ...

Upvotes: 5

garfield
garfield

Reputation: 595

In my case, I'm running an HTTP process in localhost (port 8090)

The curl request generated by pressing the Code button in Postman works fine, returning the expected results i.e:

curl -X GET 'http://localhost:8090/tel-2/customers' -H 'Content-Type: application/json'

When I attempt to run it through the GUI I get back an HTTP 400 with an HTML error response as follows (<style> section omitted for brevity).

<!doctype html>
<html lang="en">

<head>
    <title>HTTP Status 400 – Bad Request</title>
</head>

<body>
    <h1>HTTP Status 400 – Bad Request</h1>
</body>

</html>

When I access the URL through the browser also works fine.

I have attempted to re-install Postman but the problem persists. The Postman version that I'm using is Desktop 7.31.1, the latest at the moment.

Finally, I uninstalled Postman desktop completely and the older Chrome version 5.5.5 works as expected.

Upvotes: 2

Vlad Moyseenko
Vlad Moyseenko

Reputation: 223

My problem isn't directly related to Postman but was in adding an extra / to end of REST resource, so I got 404. The solution is simply do not add extra space for the REST listing resource:

example.com/api/items/ -> example.com/api/items

Upvotes: 1

mobject
mobject

Reputation: 179

In my case, I was accidentally added extra / e.g: www.test.com//endpoint in Postman address but when saving to CODE, Postman reformatted it and removed extra /.

Upvotes: 3

Jason Owens
Jason Owens

Reputation: 26

Are you behind a proxy? I'm having a similar issue and I believe the issue is the handshaking protocol with the proxy not being applied to the postman application.

Upvotes: 1

Peter
Peter

Reputation: 21

In my case, the request was failing because I was hitting an internal resource being served over HTTPS. Disabling SSL Certificate Validation in the Postman preferences fixed it for me.

Upvotes: 2

Jainam Jhaveri
Jainam Jhaveri

Reputation: 1561

My API request was taking around 4000ms to return a response while timeout was set to 1000ms in postman settings.

After I set Settings->General->Request timeout in ms(0 for infinity) to 0, it started working fine.

Upvotes: 0

Edy
Edy

Reputation: 121

In my case, only the requests to localhost were working. This happened after it synchronized with other instances I was logged into.

After I disabled SSL certificate verification in Settings->General, it started working again.

Upvotes: 10

ennovation
ennovation

Reputation: 366

Intermittently happened to me as well. I tried these steps:

  • Go to settings, disable Send Postman Token Header
  • Disable Interceptor (The satellite icon at the top)

Not sure why, but it simply worked!

Upvotes: 12

Related Questions