I have the following problem:
I have created .NET classes using the SalesForce OpenAPI specification and have the problem that I cannot update an account using an external ID.
There is an AccountPATCH method that expects an ID, a content type and the body (payload) as parameters.
The call then looks like this, for example:
Webhook.AccountPATCH(AccountId,'application/json', AccountSObject);
AccountId is a string variable and AccountSObject is the account object. If I use the Salesforce AccountID as AccountID, AccountPATCH works fine.
But how can I use an external ID?
For example, I want to use the ContactNumberNav__pc field (which is a unique and external ID field).
I currently get the following error message:
Error when calling SalesForceAPI.Webhook.AccountPATCH with the following message: Status Code 404
Status: 404 Response: [{"errorCode": "NOT_FOUND", "message": "Provided external ID field does not exist or is not accessible: 1331054"}]
What can I do to make this work?
Through various extensions to the OpenAPI document, I was able to solve the problem myself.
First, I added the new paths to the document.
As an example: "/sobjects/Account/CustomerNumberNav__c/{id}".
I also had to specify an operationID for the individual HTTP methods GET,DELETE,PATCH so that NSwag did not generate duplicate function names.
Strangely, the PATCH call to the new path did not return an HTTP 204 Success, but instead an HTTP 200. I had to add that the HTTP 200 is also a valid response code.