2

I'm trying to use the partner API to upsert Account objects:

SObject account = new SObject();
account.setType("Account");

// set some fields
account.setField("Name", "Spacely Sprockets");

// write that bad boy
connection.upsert("Id", new SObject[] { account });

This works until I try to set the account's type:

account.setField("type", "Partner");

Which causes the upsert to error:

[ApiFault exceptionCode='INVALID_TYPE'
exceptionMessage='sObject type 'Prospect' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.' ]

Say what? I clearly set the SObject's type to "Account", not "Partner". Okay – let's look at the source code for setType(String):

public void setType(String type) {
    setField("type", type);
}

Well, that makes sense, in its own special way. The setField("type", "Partner") overwrote the type specified setType("Account"). But that still doesn't help me solve my original problem:

How do I set an Account object's type with the Partner API, using com.sforce.soap.partner.sobject.SObject or otherwise?

1 Answer 1

4

It appears that this is one of those times that Salesforce's API is actually case-sensitive: changing "type" to "Type" solves the problem.

account.setField("Type", "Partner");

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .