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
OHT APIOHT API 

"Unable to find a deserializer" error when using php toolkit

Hello everyone,

Searched this topic for the better part of this day, but no solution came up.

Im encountring a strange message while trying to create a new contact.
$username = "Username"; /* edited out */
$password = "Password"; /* edited out */
$token = "token"; /* edited out */
$auth = $password . $token;
$connection = new \SforceEnterpriseClient();
$connection->createConnection(Manager::WSDL); /* the location of the wsdl file is correct */
$loginResponse = $connection->login($username, $auth); /* Login is successful */
Up until this point everything is going smooth. Now, Im trying to do a create contact request:
try {
        //Creating the Contact
        $contact = new \Contact();
        $contact->FirstName = "First";
        $contact->LastName = "Last";

        $response = $connection->create(array($contact), 'Contact');
        var_dump($response);
} catch (Exception $e) {
        echo $e->getMessage();
}

This is a simplified case which reproduces the problem over my system.
The problem is, an exception is thrown. The last "echo" prints out 
Unable to find a deserializer for the type common.api.soap.wsdl.QueryResult Error Id: 1664238328-34686 (2133394444)
Seems like its coming from the SoapClient itself. but i might be wrong.

Im using SoapClient native package of PHP5.3.
If any other data needed, please ask and i'll provide ASAP.

Would appreciate any suggestion or tips on this issue.

Thank you very much in advance
 
ShashankShashank (Salesforce Developers) 
Could you please let me know if you are still facing this issue?
Chris BowmanChris Bowman
As of today I am seeing this error too:

Uncaught SoapFault exception: [soapenv:Server] Unable to find a deserializer for the type common.api.soap.wsdl.QueryResult Error Id: 1029389879-113259 (-1340098697)
Chris BowmanChris Bowman
So I figured this out.  Hopefully this helps future rookies.

My code was sending every field/property of a custom SalesForce object.  Many of the values for these field/properties were empty.  When I changed the code to only send field/properties with valid values the create request processed fine.

So for the example code posted at the beginning of this thread:  I would pass the Conact instance as the $_fullObj parameter to this funtion, then pass the returned object to the create call.
 
function makeStdClassObj($_fullObj) {
        $stdObj = new stdclass();
        $props = get_object_vars($_fullObj);
        foreach ($props as $name => $val) {
            if (!empty($val)) {
                $stdObj->$name = $val;
            }
        }
        return $stdObj;
    }
There may be a better way to do this, possibly using the fieldsToNull special property for the 'empty' fields/porperties, but this seemed simple for my implementation.
 
Kirill_YunussovKirill_Yunussov
I spent a few hours troubleshooting this undescriptive error today until finally found the cause. 

I was getting this message when trying to update a list of Opportunity records.  Turned out that this was because I was updating the same object that I got from a query, and one (or more) of the queried fields on that object were not writable.   I think it was either "recordtype.name" or "amount".  What I ended up doing was creating a new instance of Opportunity object for update purposes.

1) Query for the Opportunity records, including related lists, and certain non-writable fields.
2) Instead of updating the objects you get from the query in Step# 1, create a NEW List of NEW Opportunities for update purposes, and only populate the fields that you want to update.

    ArrayList<Opportunity> queryOpps = apiCaller.executeQuery(queryString);
    ArrayList<Opportunity> updateOpps = new ArrayList<Opportunity>();
    
    for (Opportunity queryOpp : queryOpps) {
        // some condition for update
        if (queryOpp.getAmount() < queryOpp.getProjected_Revenue__c()) {
    
            // create a new Opportunity, instead of adding the queryOpp to the update list 
            Opportunity updateOpp = new Opportunity();
            updateOpp.setId(queryOpp.getId());
            updateOpp.setStageName("Needs Review");
            updateOpps.add(updateOpp);
        }
    }
    
    apiCaller.update(updateOpps);