What should I use patch or put in my Rest API?

What should I use patch or put in my Rest API?

Either you are “adding”, “removing” or “updating” an activation on a Group, or if you prefer: manipulating a “status”-resource on a Group. Personally, I’d use “activations” because they are less ambiguous than the concept “status”: creating a status is ambiguous, creating an activation is not.

How to simplify your API code with new composite resources?

Use the SObject Rows resource with the Account ID and Contact ID to update the existing Contact and assign it to the Account via a PATCH to /services/data/v38.0/sobjects/Contact. In most cases this would require at least three REST API calls. That’s a fair amount of round-trips to Salesforce and back for a relatively simple task.

What happens if you use patch data in a put request?

Since PUT requests include the entire entity, if you issue the same request repeatedly, it should always have the same outcome (the data you sent is now the entire data of the entity). Therefore PUT is idempotent. What happens if you use the above PATCH data in a PUT request?

Can you use composite resources in Salesforce REST API?

Salesforce recently added the composite resources (batch, tree, and composite) to the Salesforce REST API. You can use the composite resources to make multiple requests using a single REST API call.

How to implement a patch executed via resttemplate?

You can configure RestTemplate to use some other HTTP client via client factory, like HttpComponentsClientHttpRequestFactory or OkHttpClientHttpRequestFactory. You will also need to add proper dependencies, something like org.apache.httpcomponents:httpclient:$version in case HTTP Components client.

What is the content type of a JSON Patch request?

Most importantly, the Content-Type for JSON Patch requests is application/json-patch+json. Also, the request body is an array of JSON Patch operation objects: