• rhinmass
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies

(I originally posted this in Java Development, but I think the question is general to the API.)

 

I have found documentation on how to create an Account and Contact in one API call, yet when I try it I get an error.  There seems to be a contradiction in what the documentation states and what the API will accept.

 

The document reference is:

 

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_create.htm#MixedSaveSection

 

... and states:

 

You can create records for multiple object types, including custom objects, in one call with API version 20.0 and later. For example, you could create a contact and an account in one call. You can create records for up to 10 object types in one call. 

 

Java examples are shown where an Account and Contact are passed to the create call.

 

 

Yet when I try this I get:

 

Exception in thread "main"       ...

...

Caused by: com.sforce.soap.enterprise.InvalidSObjectFault: INVALID_TYPE: all sObjects in create or update must be of same type

      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

      at java.lang.reflect.Constructor.newInstance(Unknown Source)

      at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:127)

      at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:119)

      at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:89)

      at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:118)

      at $Proxy46.create(Unknown Source)

      ... 1 more

 

I have checked the API version we are using and it is Salesforce.com Enterprise Web Services API Version 23.0

 

Here is the code snippet:

 

List<SObject> sobjects = new ArrayList<SObject>();
Contact contact = new Contact();
//... set stuff on the contact
Account account = new Account();
account.setAccountId__C(getJAXBElement("AccountId__C", Double.class, getId()));
//crete the account reference and add to the contact
Account accountReference = new Account();
accountReference.setAccountId__C(getJAXBElement("AccountId__C", Double.class, getId()));
contact.setAccount(getJAXBElement("Account", Account.class, accountReference));

sobjects.add(account);
sobjects.add(contact);
apiContext.getPort().create(sobjects);

 

Thanks for any assistance!

Robin

I have found documentation on how to create an Account and Contact in one API call, yet when I try it I get an error.  There seems to be a contradiction in what the documentation states and what the API will accept.

 

The document reference is:

 

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_create.htm#MixedSaveSection

 

... and states:

 

You can create records for multiple object types, including custom objects, in one call with API version 20.0 and later. For example, you could create a contact and an account in one call. You can create records for up to 10 object types in one call. 

 

Java examples are shown where an Account and Contact are passed to the create call.

 

 

Yet when I try this I get:

 

Exception in thread "main"       ...

...

Caused by: com.sforce.soap.enterprise.InvalidSObjectFault: INVALID_TYPE: all sObjects in create or update must be of same type

      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

      at java.lang.reflect.Constructor.newInstance(Unknown Source)

      at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:127)

      at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:119)

      at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:89)

      at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:118)

      at $Proxy46.create(Unknown Source)

      ... 1 more

 

I have checked the API version we are using and it is Salesforce.com Enterprise Web Services API Version 23.0

 

Here is the code snippet:

 

List<SObject> sobjects = new ArrayList<SObject>();
Contact contact = new Contact();
//... set stuff on the contact
Account account = new Account();
account.setAccountId__C(getJAXBElement("AccountId__C", Double.class, getId()));
contact.setAccount(getJAXBElement("Account", Account.class, account));
//crete the account reference and add to the array
Account accountReference = new Account();
accountReference.setAccountId__C(getJAXBElement("AccountId__C", Double.class, getId()));
sobjects.add(accountReference);
sobjects.add(contact);
apiContext.getPort().create(sobjects);

 

Thanks for any assistance!

Robin

I have found documentation on how to create an Account and Contact in one API call, yet when I try it I get an error.  There seems to be a contradiction in what the documentation states and what the API will accept.

 

The document reference is:

 

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_create.htm#MixedSaveSection

 

... and states:

 

You can create records for multiple object types, including custom objects, in one call with API version 20.0 and later. For example, you could create a contact and an account in one call. You can create records for up to 10 object types in one call. 

 

Java examples are shown where an Account and Contact are passed to the create call.

 

 

Yet when I try this I get:

 

Exception in thread "main"       ...

...

Caused by: com.sforce.soap.enterprise.InvalidSObjectFault: INVALID_TYPE: all sObjects in create or update must be of same type

      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

      at java.lang.reflect.Constructor.newInstance(Unknown Source)

      at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:127)

      at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:119)

      at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:89)

      at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:118)

      at $Proxy46.create(Unknown Source)

      ... 1 more

 

I have checked the API version we are using and it is Salesforce.com Enterprise Web Services API Version 23.0

 

Here is the code snippet:

 

List<SObject> sobjects = new ArrayList<SObject>();
Contact contact = new Contact();
//... set stuff on the contact
Account account = new Account();
account.setAccountId__C(getJAXBElement("AccountId__C", Double.class, getId()));
contact.setAccount(getJAXBElement("Account", Account.class, account));
//crete the account reference and add to the array
Account accountReference = new Account();
accountReference.setAccountId__C(getJAXBElement("AccountId__C", Double.class, getId()));
sobjects.add(accountReference);
sobjects.add(contact);
apiContext.getPort().create(sobjects);

 

Thanks for any assistance!

Robin