使用External Id的Salesforce Upsert会产生INVALID_FIELD错误(Salesforce Upsert using External Id gives an INVALID_FIELD Error)

我在SFDC中有一个带有外部id extId__c的自定义对象obj__c 。 根据https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_upsert.htm中的文章,我做了一个/services/data/v40.0/sobjects/obj__c/extId__c/45754?_HttpMethod=PATCH在Workbench上调用/services/data/v40.0/sobjects/obj__c/extId__c/45754?_HttpMethod=PATCH 。 如果已经存在具有extId 45754的obj__c ,它将更新记录。 但是如果obj__c不存在则抛出以下错误(基本插入)。

message: The extId__c field should not be specified in the sobject data. errorCode: INVALID_FIELD

I have a custom object obj__c with external id extId__c in SFDC. Based on the article in https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_upsert.htm I do a /services/data/v40.0/sobjects/obj__c/extId__c/45754?_HttpMethod=PATCH call on Workbench. It updates the the record, if an obj__c with extId 45754 already exists. But if the obj__c doesn't exist then the following error is thrown (Basically Insertion).

message: The extId__c field should not be specified in the sobject data. errorCode: INVALID_FIELD

最满意答案

API版本37.0之后有一些更改,建议使用POST替换插入而不是PATCH。 您可以尝试将版本更改为v36.0(或小于37),例如:/services/data/v36.0/sobjects/obj__c/extId__c/45754?_HttpMethod=PATCH

I finally figured out the issue. I was passing extId__c field in the payload body also, which is forbidden.

使用External Id的Salesforce Upsert会产生INVALID_FIELD错误(Salesforce Upsert using External Id gives an INVALID_FIELD Error)

我在SFDC中有一个带有外部id extId__c的自定义对象obj__c 。 根据https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_upsert.htm中的文章,我做了一个/services/data/v40.0/sobjects/obj__c/extId__c/45754?_HttpMethod=PATCH在Workbench上调用/services/data/v40.0/sobjects/obj__c/extId__c/45754?_HttpMethod=PATCH 。 如果已经存在具有extId 45754的obj__c ,它将更新记录。 但是如果obj__c不存在则抛出以下错误(基本插入)。

message: The extId__c field should not be specified in the sobject data. errorCode: INVALID_FIELD

I have a custom object obj__c with external id extId__c in SFDC. Based on the article in https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_upsert.htm I do a /services/data/v40.0/sobjects/obj__c/extId__c/45754?_HttpMethod=PATCH call on Workbench. It updates the the record, if an obj__c with extId 45754 already exists. But if the obj__c doesn't exist then the following error is thrown (Basically Insertion).

message: The extId__c field should not be specified in the sobject data. errorCode: INVALID_FIELD

最满意答案

API版本37.0之后有一些更改,建议使用POST替换插入而不是PATCH。 您可以尝试将版本更改为v36.0(或小于37),例如:/services/data/v36.0/sobjects/obj__c/extId__c/45754?_HttpMethod=PATCH

I finally figured out the issue. I was passing extId__c field in the payload body also, which is forbidden.