Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3672

REST API - Handling an empty body in PATCH

$
0
0

I am currently contributing to a REST API written in Go and I was facing an existential question.

How are we supposed to handle an empty body in a PATCH? Knowing that a PATCH is used to update an existing data, are we supposed to return an error code (4XX) or an ok status (2XX)?

For example, if I have the following route: /user/:id

And a user has the following structure:

type User struct {  Name string  Email string}

So if we PATCH a specific user, we will either have a body containing the name or the email.

What should we do if it is empty?

The RFC5789 was not a real help (2.2 for error handling)

https://datatracker.ietf.org/doc/rfc5789/?include_text=1


Viewing all articles
Browse latest Browse all 3672

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>