2

I am making a PATCH request to update a contact in Salesforce via API. The resource seems to be updated fine, but it returns me 204 No Content in POSTMAN.

To my knowledge, it just means that there was no body returned in response which makes sense, since its PATCH method. But just wanted to confirm, Is it an error that I should be worried about?

0

3 Answers 3

4

204 No Content does not mean an error code. It still reflects a successful operation. This is from the MDN docs:

The common use case is to return 204 as a result of a PUT request, updating a resource, without changing the current content of the page displayed to the user.

Additionally, Status Codes and Error Responses documentation lists the different status codes that are used in Salesforce REST API Contexts.

Irrespective of the context where it is used, the status code 204 is always a successful response.

1
  • 2
    It's worth noting from a general web development point of view that any 2xx response code should be considered successful (3xx means redirection, 4xx means a problem with the client request, and 5xx means a problem with the server).
    – sfdcfox
    Commented Jun 7, 2019 at 17:35
4

HTTP status code 204 is returned if an existing record is updated.

here are the salesforce docs on PATCH

JSON example response HTTP status code 204 is returned if an existing record is updated.

https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_upsert.htm#!

2

It is fine to get 204 No Content using the PATCH method as long as you are using REST API version 45.0 and earlier:

In API version 45.0 and earlier, the HTTP status code is 204 (No Content) and there is no response body

In API version 46.0 and later, the HTTP status code is 200 (OK) and the successful response is:

{
    "id" : "001D000000Kv3g5IAB",
    "success" : true,
    "errors" : [ ],
    "created": false
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .