+ Start a Discussion


I am trying to create a new order programmatically (c#) using the CreateAsync method but although it returns a unique ID, I am unable to find the order created within the Salesforce back office.

The following is an extract of the code:

Salesforce.Force.ForceClient myforceclient = new ForceClient(instanceUrl, accesstoken, apiVersion);
dynamic order = new ExpandoObject();
(then create all the properties, ie AccountID, ContractID etc)

Then implement the CreateAsync
 var orderres = myforceclient.CreateAsync("Order", order);
Daniel BallingerDaniel Ballinger

CreateAsync should return a SuccessResponse (https://github.com/developerforce/Force.com-Toolkit-for-NET/blob/313c4b9106b9a0f9779d42514189addc713799a5/src/CommonLibrariesForNET/Models/Json/SuccessResponse.cs). Is the Success property on that record true? If not, check the Errors property.

When checking for the record by ID, are you using the same Salesforce user? It might be that by using different users you no longer have access to the record in question.

Jeremiah BaylesJeremiah Bayles

What gives?, the method createAsync I'm using returns void... I"m using the enterpriseWSDL, which one are you using?

Confusing part is when I use just the method I get an exception telling me: {"An asynchronous operation cannot be started at this time. Asynchronous operations may only be started within an asynchronous handler or module or during certain events in the Page lifecycle. If this exception occurred while executing a Page, ensure that the Page is marked <%@ Page Async=\"true\" %>. This exception may also indicate an attempt to call an \"async void\" method, which is generally unsupported within ASP.NET request processing. Instead, the asynchronous method should return a Task, and the caller should await it."}