Wednesday, November 27, 2013

InvalidSObjectFault INVALID_TYPE

Today, I spent a while trying to figure out why my calls to get an object via the Partner API failed.

In code I composed a query, just like usual, and made the call, just like usual but I got this error

[InvalidSObjectFault [ApiQueryFault [ApiFault  
    exceptionMessage='Select ... FROM MyCustomObject__c ...'

    sObject type 'MyCustomObject__c' 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.']

A searched for help on "InvalidSObjectFault" is frustrating and didn't help. The object "MyCustomObject__c" is valid. I could run the same query in the SoqlXplorer ( ).  So I could easily verify the query was good. I retrieved the object class files and inspected them without any clue. Next I used my other posting about rebuilding the partner jar file to get the latest V29, just in case this was a versioning issue. 


Turns out the solution is simple yet the error message sends you completely way off base.


Check the user's profile permissions on the object. If the user does not have permission then API responds with InvalidSObjectFault.

(Why couldn't the description of this fault include the fact that the sObject may be valid yet the user lacks permission?)