Entity Key isn't set
See original GitHub issueHi!
When using this library to query an SAP ByD OData service I get an empty entity:
When I enable debugger it looks like it’s getting the data I want, just not setting the entity as expected/putting it somewhere I can access (see the last debug statement, I put ** around it):
>>> threads = byd_client.entity_sets.BusinessPartnerCollection.get_entity('00163E0DBAC41ED7AD87562C419D1A6C').execute()
...
DEBUG:pyodata.service:Detected single property key, adding pair ObjectID->00163E0DBAC41ED7AD87562C419D1A6C to keyproperties
INFO:pyodata.service:Getting entity BusinessPartner for key 00163E0DBAC41ED7AD87562C419D1A6C and args {}
DEBUG:pyodata.service:New instance of EntityGetRequest for last segment: BusinessPartnerCollection
DEBUG:pyodata.service:Send (execute) GET request to https://my340402.sapbydesign.com/sap/byd/odata/cust/v1/accountinfo/BusinessPartnerCollection('00163E0DBAC41ED7AD87562C419D1A6C')
DEBUG:pyodata.service: query params: {}
DEBUG:pyodata.service: headers: {'Accept': 'application/json'}
DEBUG:urllib3.connectionpool:https://my340402.sapbydesign.com:443 "GET /sap/byd/odata/cust/v1/accountinfo/BusinessPartnerCollection('00163E0DBAC41ED7AD87562C419D1A6C') HTTP/1.1" 200 576
DEBUG:pyodata.service:Received response
DEBUG:pyodata.service: url: https://my340402.sapbydesign.com/sap/byd/odata/cust/v1/accountinfo/BusinessPartnerCollection('00163E0DBAC41ED7AD87562C419D1A6C')
DEBUG:pyodata.service: headers: {'content-type': 'application/json; charset=utf-8', 'content-length': '576', 'cache-control': 'no-cache, no-store', 'dataserviceversion': '2.0', 'c4c-odata-response-time': '111 ms', 'strict-transport-security': 'max-age=31536000; includeSubDomains'}
DEBUG:pyodata.service: status code: 200
DEBUG:pyodata.service: body: {"d":{"results":{"__metadata":{"uri":"https://my340402.sapbydesign.com/sap/byd/odata/cust/v1/accountinfo/BusinessPartnerCollection('00163E0DBAC41ED7AD87562C419D1A6C')","type":"cust.BusinessPartner"},"ObjectID":"00163E0DBAC41ED7AD87562C419D1A6C","RoleCode":"CRM000","StartDate":"\/Date(-62135769600000)\/","EndDate":"\/Date(253402214400000)\/","InternalID":"1060169","BusinessPartnerDefaultWeb":{"__deferred":{"uri":"https://my340402.sapbydesign.com/sap/byd/odata/cust/v1/accountinfo/BusinessPartnerCollection('00163E0DBAC41ED7AD87562C419D1A6C')/BusinessPartnerDefaultWeb"}}}}}
**DEBUG:pyodata.service:New entity proxy instance of type BusinessPartner from properties: {'results': {'__metadata': {'uri': "https://my340402.sapbydesign.com/sap/byd/odata/cust/v1/accountinfo/BusinessPartnerCollection('00163E0DBAC41ED7AD87562C419D1A6C')", 'type': 'cust.BusinessPartner'}, 'ObjectID': '00163E0DBAC41ED7AD87562C419D1A6C', 'RoleCode': 'CRM000', 'StartDate': '/Date(-62135769600000)/', 'EndDate': '/Date(253402214400000)/', 'InternalID': '1060169', 'BusinessPartnerDefaultWeb': {'__deferred': {'uri': "https://my340402.sapbydesign.com/sap/byd/odata/cust/v1/accountinfo/BusinessPartnerCollection('00163E0DBAC41ED7AD87562C419D1A6C')/BusinessPartnerDefaultWeb"}}}}**
INFO:pyodata.service:Initiating property request for __len__
INFO:pyodata.service:Initiating property request for __len__
INFO:pyodata.service:Initiating property request for url
As a result I seem to get an error when I try to get a property from that:
>>> threads.InternalID
INFO:pyodata.service:Initiating property request for InternalID
Traceback (most recent call last):
File "C:\Users\dwilliams\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyodata\v2\service.py", line 783, in __getattr__
return self._cache[attr]
KeyError: 'InternalID'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Users\dwilliams\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyodata\v2\service.py", line 786, in __getattr__
value = self.get_proprty(attr).execute()
File "C:\Users\dwilliams\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyodata\v2\service.py", line 847, in get_proprty
path = urljoin(self.get_path(), name)
File "C:\Users\dwilliams\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyodata\v2\service.py", line 830, in get_path
return self._entity_set._name + self._entity_key.to_key_string() # pylint: disable=protected-access
AttributeError: 'NoneType' object has no attribute 'to_key_string'
INFO:pyodata.service:Initiating property request for __len__
INFO:pyodata.service:Initiating property request for __len__
INFO:pyodata.service:Initiating property request for url
If I do something like this, it sets the entity key for each entity:
>>> bp_coll = byd_client.entity_sets.BusinessPartnerCollection.get_entities().select('ObjectID,InternalID').execute()
>>> print(bp_coll[0].InternalID)
'NBS'
Am I doing something wrong here…?
Thanks for your time and expertise, Dan Williams
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
entity key - ADO.NET | Microsoft Learn
An entity key is a property or a set of properties of an entity ... entity key for a given entity type; surrogate...
Read more >Not able to set RecId as Entity Key during creation...
Not able to set RecId as Entity Key because i am getting only these field in the drop down.(Please refer the image attached)....
Read more >JPA hibernate foreign key not set in entity - Stack Overflow
1. We need a complete minimal example to understand what you're doing (transaction boundaries, etc.). 2. You shouldn't have a prentId field in ......
Read more >The primary key fields are not set for this descriptor
Hello I am working on a new toplink project, I have a question regarding whether to set a primary key for a table?...
Read more >How to create a custom entity for Dual-write
In today's article, I will show how you can create your own custom Dual Write integrations between Dynamics 365 Supply Chain Management and ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yep, sorry about that, I forgot to mention that I need only the entity.
Thank you! Now, I will try to fix the problem.
Hi @sti0 ! I do it like this: