-
-
Notifications
You must be signed in to change notification settings - Fork 159
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
Cannot parse server response for status code 204 on delete request #245
Comments
Hi @pcantrell do you have any suggestion for a workaround? |
The “Cannot parse server response” error means that something in the transformer pipeline returned an error. If you look in the logs, there should be an accompanying underlying error. (You may need to enable more Siesta log categories to get the full info.) Two likely causes:
In either case, one blanket solution is to disable the entire response transformer pipeline for all service.configure("**", requestMethods: [.delete]) {
$0.removeAllTransformers()
} Make sure to do that after configuring your own specific transformers. Siesta applies configuration in the order you specify it. (You might want to only disable process for specific pipeline stages if you have some transformers that do useful things with headers, errors, etc.) If it is one of your model transformers that is failing, another less ham-handed approach is to configure your model transformer only for specific request methods: service.configureTransformer("/users/*", requestMethods: [.get, .put, .post]) {
try jsonDecoder.decode(User.self, from: $0.content)
} |
Hi @pcantrell, Thanks for the reply! The error is:
So the response has a 204 status code, the body is blank and the Content Type is not JSON. What I can't derive from your answer is whether this is expected behavior or a bug? It does not seem logical to me that if setting a 204 status code it still attempts to parse the body. |
You need to look up above that in the log, where the transformer pipeline is being applied to the response. If you enable logging for The question here is why it’s trying to apply a transformer that expects JSON. Is it because the server sent a content type that triggered default JSON parsing? Is it because you configured a model transformer that's kicking in? |
Hi,
I really like this library, thanks for creating this!
Noticed a small issue today. I have an API which responds with a
204
(no content) status code on a successfulDELETE
request and thus has no content in the response body. This makes sense to me.However Siesta considers this to be an error
Cannot parse server response
.Is this intended behavior? This issue is similar to #11 except that issue was concerning a
POST
request, not aDELETE
request.P.s. I made sure my API does not set a Content-Type header.
The text was updated successfully, but these errors were encountered: