-
Notifications
You must be signed in to change notification settings - Fork 851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could not get any response when 204: No Content returned from server #2418
Comments
Just had a thought on this actually, could it be the |
Which API are you using? Can you try doing the same using |
@madebysid That works for me fine. The API is our own private API so sadly I can't open it up for poking, I might try when the response returns |
@DCRichards Did you manage to reproduce this? |
@madebysid I've not yet found an isolated test case. What I have seen is when proxying the same API call through a different server (so the 204 response is the same, but sent from my proxying server rather than the other), postman responds correctly, so it's something specific to that server. It's wordpress using the Oauth2 plugin but not sure why that's making a difference.... |
@DCRichards This is just a thought, but do you perform a redirect in any way with your old setup? The app will, by default, try to follow these redirects. Can you try switching off automatic redirects in Settings > General and see if the problem persists? |
Ah, that's a thought @madebysid, I'll give it a try and let you know! Thank you |
I'm facing the same issue, also on a private API :( If I copy the
I was also outputting Linux Mint 18, Postman desktop 4.8.1. Nothing useful shows on the console, as with the OP. |
Actually, while testing out I removed the content-type while changed the timeout setting to a bad value. I found no clear, canonical answer on 204 vs. Content-Type, but from my humble interpretation, 204 should ideally not send a Content-Type header, as there's no content to encode neither would be (as in the case of a HEAD response):
Thus, it feels that Postman is correct on trying to parse something that has a content-type. Maybe a warning should be added to that list of suggestions, stating that empty responses should not contain a content-type? Or should it be a cool guy and skip parsing if the response is empty? |
The problem is still there. Postman has a confusing behavior on
Please, make Postman able to display at least HTTP response status 204 or better along with a response body. |
Some problem here. |
Same problem here (Windows App), works on Chrome App. |
Problem still exists in version 5.1.2 |
Still having this issue. |
I do not think it is supposed to return anything by standards. See https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html The 204 response MUST NOT include a message-body, and thus is always terminated by the first empty line after the header fields. Oh. duh @igorsantos07 already said this. :) |
In my case, perhaps I have misinterpreted the reason to return 204. I am using it when a query seeking records does not find any. No records, return 204 (no content).
But perhaps I DO need to return data and should return status 200 OK and return a message such as Which would be best for the developer? Status 204 (No content) or Status 200 (OK) with empty record set and/or message? I do not think either breaks any rules or interpretation of status codes necessarily. |
@developer99 I suggest you to post those questions on a forum such as StackOverflow. That's off-topic, as we're discussing here an issue with Postman interpretation of 204 responses :)
|
same issue here |
I can confirm that this is happening for me and another of my colleagues as well. It happens regardless of whether the request has a body or not. |
I am having this issue as well. |
This is a problem for me as well, if I do this request in curl, I get the correct response:
But Postman shows me the confusing "Could not get any response" and no way to view the headers to see that I did in fact get a 204. |
I am having same issue as well. anyone have any solution ? |
I think it's not the problem of Postman. As @igorsantos07 said, we should follow the HTTP specification. Make sure there is no body in the response if it returns 204. Otherwise, ask the APIs service provider first. |
Totally agree with @igorsantos07 and @yanxiaodi . I had the same issue, I was testing some stuff so I got some testing messages in the code and were returning 204 response with notorious "Could not get any response" message in postman. |
Hey... I took a dig at locally reproducing this. Phew! Getting a server to misbehave is really tricky. I am very comfortable with NodeJS and sadly I could not create a server that would send 204 and body. I am sure of one thing though - can confirm that 204 without body works fine on Postman, irrespective of request method / header / whatever. I will switch to some low-level language to make a misbehaving server. PS If anyone has anything handy to speed me up, let me know. The test code I used (not relevant):
|
I had a silly issue causing this same problem for a little while. For me I was returning a 204 with 'Success' set to false. -_- |
Returning content with a 204 status code is a violation of the HTTP spec and causes several pieces of software (including Chrome) to act in odd, difficult-to-debug ways[1]. Specifically, when the /api/users/me/vote endpoint was returning a 204 with the body '{\n "status_message": "success"\n}', it was causing Chrome to fail the request and therefore a .then() callback didn't run, but Axios presumably doesn't treat 2xx status codes as errors, so the error handler wasn't being run either! [1]: dotnet/aspnetcore#4398, postmanlabs/postman-app-support#2418
I ran into this same issue today and it cost me a few hours thinking it was my code that was the issue. I encountered the issue when trying to set up Lavavel Sanctum and hitting the /sanctum/csrf-cookie route, which returns a 204 with no content and 2 cookies. macOS 10.15.4 running Laravel Valet. |
@eysikal Did you find any suitable solution for this? Postman seems to just throw |
@Niush No, I never did. I ended up using Chrome extension tool to test my API and that’s when I discovered that it was Postman that had the issue. |
@eysikal We have made some recent changes to resolve this. What version of our application are you using currently? |
@mccannt After latest update (Windows Version 7.31.1) it is working from Build View just fine. pm.sendRequest({
url: pm.environment.get('base_web_url')+'/sanctum/csrf-cookie',
method: 'GET',
}, function (error, response, {cookies}) {
// THROWS ERROR: TypeError: Cannot destructure property 'cookies' of 'undefined' as it is undefined.
}) And console.log of response has 0 cookie and 0 header. (Although, it does exist as it works from Build view) I also tested with |
Thanks for the follow-up @Niush I agree that this does sound like an isolated issue with Laravel Sanctum as this appears to work as expected when hitting other valid endpoints that return a 204. Closing this issue for the time being. If this is still an issue against endpoints other than Laravel Sanctum, please feel free to reopen with details on how to replicate this. |
@eysikal Now, you need to pass pm.sendRequest({
url: `${pm.variables.get('host')}/sanctum/csrf-cookie`,
method: 'GET',
header: {
'Accept': 'application/json'
}
}, function (error, response, { cookies }) {
if (!error) {
pm.environment.set('xsrf-token', cookies.get('XSRF-TOKEN'))
}
}) |
@nmfzone Thanks for this comment it was really helpful. |
I faced a similar issue in Laravel. In my case, it turned out to be something adding extra bytes to the response. I could spot it with curl:
Since it was a new project, I decided to do a full reinstall, which resolved the problem. It was likely an unintended extra line or hidden character somewhere in the code—tricky to pinpoint, but a clean reinstall did the trick. |
Error: Parse Error
in console, but with no further information.Steps to reproduce the problem:
Could not get any response
displayed and the status code not shown as 204, instead just the messageThere was an error connecting to <URL>
The text was updated successfully, but these errors were encountered: