function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jpollackjpollack 

REST API uses the PATCH verb, which isn't supported by httpcomponents. Any way around this?

Apparently, to do an upsert from the REST API, one must make a PATCH request.  PATCH is not one of the common HTTP verbs and thus is not supported by Apache httpcomponents.  Is there any way to do an upsert without making a PATCH request?

 

I really wish they stuck to the standard verbs when making this API.  This does not make my life easier.

SuperfellSuperfell

PATCH is a standard verb (fairly recent, but a standard). However if your tooling doesn't support it, you can make a POST request with ?_httpMethod=PATCH on the URL. 

jpollackjpollack

Thanks for the help!

 

Sadly, it looks like I can't use upsert for this.  I wanted to upsert Lead objects based on email address, but it looks like only custom fields can be external ids, and Email is a standard field :(

SuperfellSuperfell

Actually I think you should be able to upsert on Lead email, the describe says Email has the IdLookup property, which means it can be a key for upsert.

jpollackjpollack

Thanks again for the quick response.  I did try this URL and got a 404 :

 

https://na12.salesforce.com/services/data/v20.0/sobjects/Lead/Email/email_czdtcnlrzx@czdtcnlrzx.com?_httpMethod=PATCH

 

Am I doing it wrong?

jpollackjpollack

Okay, just an update.  Turns out the PATCH workaround SimonF suggested works, HOWEVER, _HttpMethod is case sensitive, so you must capitalize the H.