rajdeepd / salesforce-python-toolkit

Automatically exported from code.google.com/p/salesforce-python-toolkit
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Unable to update custom object #4

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi, first of all, thanks a lot for developing this fine library. It's working 
as promised and saving me a lot of time. I'm having this small issue though but 
I hope you can throw me some pointer to fix it.

I'm trying to update some custom object but I'm keep getting the uninformative 
'INVALID_TYPE: Must send a concrete entity type.' error.

First the explanation: I have this custom object Curso__c that has an attribute 
Dias_netos__c. According to my enterprise.wsdl it's defined as <element 
name="Dias_netos__c" nillable="true" minOccurs="0" type="xsd:double"/>

I'm generating the object, populating it with the desired Id and adding the 
Dias_netos__c attribute but when I fire the update, I always get the mentioned 
error. I tried making Dias_netos__c a float type and I also submitted a list in 
the update too (instead of a single object) but to no avail.

Here's a full example (console output from ipython):

In [2]: so = x.h.generateObject('Curso__c')

In [3]: so
Out[3]: 
(sObject){
   fieldsToNull[] = <empty>
   Id = None
   type = "Curso__c"
 }

In [4]: so.Id = "a015000000UgzNbAAJ"

In [5]: so
Out[5]: 
(sObject){
   fieldsToNull[] = <empty>
   Id = "a015000000UgzNbAAJ"
   type = "Curso__c"
 }

In [6]: so.Dias_netos__c = 4

In [7]: so
Out[7]: 
(sObject){
   fieldsToNull[] = <empty>
   Id = "a015000000UgzNbAAJ"
   type = "Curso__c"
   Dias_netos__c = 4
 }

In [9]: x.h.update([so])
12:44:21,638 ERROR [suds.client] [MainThread] <?xml version="1.0" 
encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="urn:enterprise.soap.sforce.com" 
xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:tns="urn:enterprise.soap.sforce.com" 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header>
      <tns:SessionHeader>
         <tns:sessionId>00D500000007iS2!ARkAQNaJ39HmzVnJjBwy7Ld0iSkZz4RxB3UNzQ1YY8QO7ev0XAK2S7J2WHnzLxEuuoiUZQUFeAGzl9_kR4TRIiZtuf9snoIp</tns:sessionId>
      </tns:SessionHeader>
   </SOAP-ENV:Header>
   <ns1:Body>
      <ns0:update>
         <sObjects xsi:type="ens:Curso__c">
            <Id>a015000000UgzNbAAJ</Id>
            <Dias_netos__c>4</Dias_netos__c>
         </sObjects>
      </ns0:update>
   </ns1:Body>
</SOAP-ENV:Envelope>
---------------------------------------------------------------------------
WebFault                                  Traceback (most recent call last)

/home/mariano/Code/ReportingCom/sforce/repdotcom/<ipython console> in <module>()

/home/mariano/Sandbox/reporting/lib/python2.6/site-packages/sforce/enterprise.py
c in update(self, sObjects)
     84   def update(self, sObjects):
     85     xml = self._marshallSObjects(sObjects)
---> 86     return super(SforceEnterpriseClient, self).update(xml)
     87 
     88   def upsert(self, externalIdFieldName, sObjects):

/home/mariano/Sandbox/reporting/lib/python2.6/site-packages/sforce/base.pyc in 
update(self, sObjects)
    503   def update(self, sObjects):
    504     self._setHeaders('update')
--> 505     return 
self._handleResultTyping(self._sforce.service.update(sObjects))
    506 
    507   def upsert(self, externalIdFieldName, sObjects):

/home/mariano/Sandbox/reporting/lib/python2.6/site-packages/suds-0.4-py2.6.egg/s
uds/client.py in __call__(self, *args, **kwargs)
    540                 return (500, e)
    541         else:
--> 542             return client.invoke(args, kwargs)
    543 
    544     def faults(self):

/home/mariano/Sandbox/reporting/lib/python2.6/site-packages/suds-0.4-py2.6.egg/s
uds/client.py in invoke(self, args, kwargs)
    600                 timer)
    601         timer.start()
--> 602         result = self.send(soapenv)
    603         timer.stop()
    604         metrics.log.debug(

/home/mariano/Sandbox/reporting/lib/python2.6/site-packages/suds-0.4-py2.6.egg/s
uds/client.py in send(self, soapenv)
    647             else:
    648                 log.error(self.last_sent())
--> 649                 result = self.failed(binding, e)
    650         return result
    651 

/home/mariano/Sandbox/reporting/lib/python2.6/site-packages/suds-0.4-py2.6.egg/s
uds/client.py in failed(self, binding, error)
    700         if status == 500:
    701             if len(reply) > 0:
--> 702                 r, p = binding.get_fault(reply)
    703                 self.last_received(r)
    704                 return (status, p)

/home/mariano/Sandbox/reporting/lib/python2.6/site-packages/suds-0.4-py2.6.egg/s
uds/bindings/binding.py in get_fault(self, reply)
    263         p = unmarshaller.process(fault)
    264         if self.options().faults:
--> 265             raise WebFault(p, faultroot)
    266         return (faultroot, p.detail)
    267 

WebFault: Server raised fault: 'INVALID_TYPE: Must send a concrete entity type.'

TIA,
Mariano

Original issue reported on code.google.com by Mariano....@gmail.com on 21 Sep 2010 at 3:56

GoogleCodeExporter commented 8 years ago
hmmm...  The XML looks fairly similar to this:  
http://www.salesforce.com/us/developer/resources/soap/sforce60/sforce_API_messag
es_update.html, and the code looks pretty similar to this:  
http://code.google.com/p/salesforce-python-toolkit/source/browse/trunk/EXAMPLES#
228

Can you try a couple things?
1) try against suds 0.3.9
2) try retrieving the lead by ID, then setting the field, then calling update()?

Thanks for the bug report!

David

Original comment by dlanst...@gmail.com on 21 Sep 2010 at 6:05

GoogleCodeExporter commented 8 years ago
Hi David, thanks a lot for your quick answer.
Actually I forgot to mention but I did try with retrieve, raising the same 
error.
Find below the code:

In [13]: obj = x.h.retrieve("Dias_netos__c", "Curso__c", "a0150000008Uug0AAC")

In [14]: obj
Out[14]: 
(sObject){
   fieldsToNull[] = <empty>
   Id = "a0150000008Uug0AAC"
   type = "Curso__c"
   Dias_netos__c = 1.0
 }

In [15]: obj.Dias_netos__c = 4.00

In [16]: obj
Out[16]: 
(sObject){
   fieldsToNull[] = <empty>
   Id = "a0150000008Uug0AAC"
   type = "Curso__c"
   Dias_netos__c = 4.0
 }

In [17]: x.h.update(obj)
15:25:26,598 ERROR [suds.client] [MainThread] <?xml version="1.0" 
encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="urn:enterprise.soap.sforce.com" 
xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:tns="urn:enterprise.soap.sforce.com" 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header>
      <tns:SessionHeader>
         <tns:sessionId>00D500000007iS2!ARkAQFCVlpHS0oTj2jOVj51e_ZEeGLIiDfmea.PLRX1cv0ye7z1TcmMuC33leIn6F6F6ms82fwLvKfpvKeWaWTKmIF0w9sFY</tns:sessionId>
      </tns:SessionHeader>
   </SOAP-ENV:Header>
   <ns1:Body>
      <ns0:update>
         <sObjects xsi:type="ens:Curso__c">
            <Id>a0150000008Uug0AAC</Id>
            <Dias_netos__c>4.0</Dias_netos__c>
         </sObjects>
      </ns0:update>
   </ns1:Body>
</SOAP-ENV:Envelope>
---------------------------------------------------------------------------
WebFault                                  Traceback (most recent call last)

/home/mariano/Code/ReportingCom/sforce/repdotcom/<ipython console> in <module>()

/home/mariano/Sandbox/reporting/lib/python2.6/site-packages/sforce/enterprise.py
c in update(self, sObjects)
     84   def update(self, sObjects):
     85     xml = self._marshallSObjects(sObjects)
---> 86     return super(SforceEnterpriseClient, self).update(xml)
     87 
     88   def upsert(self, externalIdFieldName, sObjects):

/home/mariano/Sandbox/reporting/lib/python2.6/site-packages/sforce/base.pyc in 
update(self, sObjects)
    503   def update(self, sObjects):
    504     self._setHeaders('update')
--> 505     return 
self._handleResultTyping(self._sforce.service.update(sObjects))
    506 
    507   def upsert(self, externalIdFieldName, sObjects):

/home/mariano/Sandbox/reporting/lib/python2.6/site-packages/suds-0.4-py2.6.egg/s
uds/client.py in __call__(self, *args, **kwargs)
    540                 return (500, e)
    541         else:
--> 542             return client.invoke(args, kwargs)
    543 
    544     def faults(self):

/home/mariano/Sandbox/reporting/lib/python2.6/site-packages/suds-0.4-py2.6.egg/s
uds/client.py in invoke(self, args, kwargs)
    600                 timer)
    601         timer.start()
--> 602         result = self.send(soapenv)
    603         timer.stop()
    604         metrics.log.debug(

/home/mariano/Sandbox/reporting/lib/python2.6/site-packages/suds-0.4-py2.6.egg/s
uds/client.py in send(self, soapenv)
    647             else:
    648                 log.error(self.last_sent())
--> 649                 result = self.failed(binding, e)
    650         return result
    651 

/home/mariano/Sandbox/reporting/lib/python2.6/site-packages/suds-0.4-py2.6.egg/s
uds/client.py in failed(self, binding, error)
    700         if status == 500:
    701             if len(reply) > 0:
--> 702                 r, p = binding.get_fault(reply)
    703                 self.last_received(r)
    704                 return (status, p)

/home/mariano/Sandbox/reporting/lib/python2.6/site-packages/suds-0.4-py2.6.egg/s
uds/bindings/binding.py in get_fault(self, reply)
    263         p = unmarshaller.process(fault)
    264         if self.options().faults:
--> 265             raise WebFault(p, faultroot)
    266         return (faultroot, p.detail)
    267 

WebFault: Server raised fault: 'INVALID_TYPE: Must send a concrete entity type.'

I will try to downgrade to suds 0.3.9 and try both examples to see what 
happens. I will let you know as soon as I'm done.

Mariano

Original comment by Mariano....@gmail.com on 21 Sep 2010 at 6:28

GoogleCodeExporter commented 8 years ago
Ok, I'm guessing it's an issue with the XML namespace prefixes - could you give 
it a try with 0.3.9 and see if that works around the issue? 

Original comment by dlanst...@gmail.com on 21 Sep 2010 at 6:34

GoogleCodeExporter commented 8 years ago
You hit the bull's-eye! Downgrading to suds 0.3.9 made the trick and I could 
update the object. Thanks a lot for your input.

Original comment by Mariano....@gmail.com on 21 Sep 2010 at 6:45

GoogleCodeExporter commented 8 years ago
Cool, I'll dig into what changed in 0.4 wrt namespace prefixes and re-release.  
Thanks again Mariano!

Original comment by dlanst...@gmail.com on 21 Sep 2010 at 6:48

GoogleCodeExporter commented 8 years ago
Issue 6 has been merged into this issue.

Original comment by dlanst...@gmail.com on 12 Jan 2011 at 9:35

GoogleCodeExporter commented 8 years ago
Added setup.py, which installs suds 0.3.9.

Original comment by dlanst...@gmail.com on 9 Jun 2011 at 6:14