Proper way to include data with an HTTP PATCH request

前端 未结 3 1579
无人共我
无人共我 2021-02-08 10:08

When I\'m putting together an HTTP PATCH request, what are my options to include data outside of URL parameters?

Will any of the following work, and what\'s the most com

3条回答
  •  故里飘歌
    2021-02-08 10:32

    There are no restrictions on the entity bodies of HTTP PATCH requests as defined in RFC 5789. So in theory, your options in this area are unlimited.

    In my opinion the only sensible choice is to use the same Content-Type used to originally create the resource. The most common choice is application/json simply because most modern APIs utilize JSON as their preferred data transfer format.

    The only relevent statement RFC 5789 makes in regard to what should and shouldn't be part of your PATCH entity body is silent on the matter of Content-Type:

    the enclosed entity contains a set of instructions describing how a resource currently residing on the origin server should be modified to produce a new version.

    In summary, how you choose to modify resources in your application is entirely up to you.

提交回复
热议问题