You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When documenting a multipart/form-data request using PATCH method, we end up with only headers in http-request snippet.
It looks like switch to multipart is only handled for PUT/POST (org.springframework.restdocs.http.HttpRequestSnippet#getRequestBody). Is there any reason for this? I didn't find any restriction about multipart and PATCH in https://datatracker.ietf.org/doc/html/rfc5789
Anyway, the restriction on PUT/POST looks like a little excessive, if body content is empty but we've parts, it's likely that we want those parts to be included in the generated snippet.
The text was updated successfully, but these errors were encountered:
Media type multipart/form-data is only defined for the POST method as per RFC 2616:
Note: The "multipart/form-data" type has been specifically defined for carrying form data suitable for processing via the POST request method, as described in RFC 1867 [15]
the operation does not modify the resource identified by the Request-URI in a predictable way that's defined by the semantics of the PATCH media type, POST should be considered instead of PATCH or PUT.
That's why MDN web docs says PATCH shouldn't be used for binary data, as stated by this answer:
1 - Well "specifically designed", doesn't mean "restricted to", I don't see any normative content in the note (no "SHOULD/MUST not be used with other HTTP methods" or so). Moreover HttpRequestSnippet already handles parts for PUT requests
2 - Don't see how multipart/form-data implies that the resource isn't modified in a predictable way
3 - The answer you quote finishes by
Uploading binary data (like images) has to be done with POST always, PUT or PATCH are used to modify the attributes of the ressource.
Don't see why a resource cannot embed binary data. Moreover, MDN isn't a normative document
wilkinsona
changed the title
multipart/form-data PATCH request produces no request body
multipart/form-data PATCH request produces http-request snippet with no request body
Jul 2, 2024
When documenting a multipart/form-data request using PATCH method, we end up with only headers in http-request snippet.
It looks like switch to multipart is only handled for PUT/POST (org.springframework.restdocs.http.HttpRequestSnippet#getRequestBody). Is there any reason for this? I didn't find any restriction about multipart and PATCH in https://datatracker.ietf.org/doc/html/rfc5789
Anyway, the restriction on PUT/POST looks like a little excessive, if body content is empty but we've parts, it's likely that we want those parts to be included in the generated snippet.
The text was updated successfully, but these errors were encountered: