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
pitaboypitaboy 

Creating Case objects using a form

I'm trying to create a form which allows a user to create a new case using C#. I'm unable to find a solution to resolve an error I get when trying to create the Case object. The error message that I'm receiving is: "UNKNOWN_EXCEPTION: Destination URL not reset. The URL returned from login must be set in the SforceService". Can someone provide insight as to how I can resolve this error? Here's is the code segment that creates the Case object.

Case caseObject = new Case();
caseObject.Description = DescriptionField.Text;
caseObject.Subject = SubjectField.Text;
caseObject.Type = TypeList.SelectedValue;

sObject[] records = new sObject[] {caseObject};
SforceService sfdc = new SforceService();

SaveResult[] results = sfdc.create(records);

if (!saveResults[0].success)
{
for(int i=0; i {
DebugOutput.Text = results[0].errors[i].message + " ";
}
}
else{
String newID = results[0].id;
}
pitaboypitaboy
I've resolved my issue by adding in the following code:

// Invoke the login call and save results in LoginResult
LoginResult lr = sfdc.login(usr,pwd);
// Reset the SOAP endpoint to the returned server URL
sfdc.Url = lr.serverUrl;
// Create a new session header
// Add the session ID returned from the login
sfdc.SessionHeaderValue = new SessionHeader();
sfdc.SessionHeaderValue.sessionId = lr.sessionId;