You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @bip91, thank you very much for taking the time to report these issues. I think we will very soon come up with an infrastructure for adding handlers for vendor bugs in OData services since We have already have several discrepancies in ByD services.
Ad 1. This definitely requires some extension point. Will think about a generic solution.
Ad 2. Are you sure it is a bug in MS CRM 2015 and not in pyodata?
I definitly agree for the first point, this cannot be solve without an extension as it is a very specific implementation of ODATA. In the meantime, I have set a condition to handle this implementation and will see later.
For second point, I am not enough skilled in Odata protocol to say what should be the correct behaviour. Perhaps examples below could help.
In all cases, pyodata raise a exception on trying to convert to a int a None Value
In the 2 first cases, because Value does not exists
In the last one, because Value is explicity set to Null
I do not see any side effect on trapping these 2 exceptions and doing nothing, perhaps it is the right thing to do.
**Case 1 and 2 : with 3 samples that raise this exception **
WARNING:pyodata.model:{'__metadata': {'type': 'Microsoft.Crm.Sdk.Data.Services.EntityReference'}, 'Id': 'f3d1cca6-0313-e711-80be-005056011e04', 'LogicalName': 'systemuser', 'Name': None}
I am afraid that the None/null issue is a bug on pyodata.
In addition to the rules stated in the table, if the value of a primitive type is null, then it is represented as an empty XML element with an m:null="true" attribute ("m" identifies the OData metadata namespace).
WARNING:pyodata.model:Exception: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
WARNING:pyodata.model:Property: Value
WARNING:pyodata.model:Value: {'__metadata': {'type': 'Microsoft.Crm.Sdk.Data.Services.OptionSetValue'}, 'Value': None}
WARNING:pyodata.model:Exception: 'NoneType' object has no attribute 'strip'
WARNING:pyodata.model:Property: Name
WARNING:pyodata.model:Value: {'__metadata': {'type': 'Microsoft.Crm.Sdk.Data.Services.EntityReference'}, 'Id': None, 'LogicalName': None, 'Name': None}
WARNING:pyodata.model:Exception: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
WARNING:pyodata.model:Property: Value
WARNING:pyodata.model:Value: {'__metadata': {'type': 'Microsoft.Crm.Sdk.Data.Services.OptionSetValue'}, 'Value': None}
WARNING:pyodata.model:Exception: 'NoneType' object has no attribute 'strip'
WARNING:pyodata.model:Property: Name
WARNING:pyodata.model:Value: {'__metadata': {'type': 'Microsoft.Crm.Sdk.Data.Services.EntityReference'}, 'Id': '7dbe6139-8dd1-e711-9105-06b4dc0315b1', 'LogicalName': 'businessunit', 'Name': None}
I have built MSCRM vendor extension : MSCRM.py.txt
This works for me with the following code :
import vendor.MSCRM
crm = vendor.MSCRM.Client(api_url_base,session)
# example to set a on guid id
crm.entity_sets.ContactSet.update_entity(id).set(**a).execute()
The endpoint has changed on more recent Dynamics CRM so the test on URL should be sufficient to avoid mistakes, but I cannot validate this (I have only Dynamics CRM 2015)
Feel free to adjust my extension to be coherent with the others.
Activity
filak-sap commentedon Apr 21, 2020
Hi @bip91, thank you very much for taking the time to report these issues. I think we will very soon come up with an infrastructure for adding handlers for vendor bugs in OData services since We have already have several discrepancies in ByD services.
Ad 1. This definitely requires some extension point. Will think about a generic solution.
Ad 2. Are you sure it is a bug in MS CRM 2015 and not in pyodata?
bip91 commentedon Apr 22, 2020
I definitly agree for the first point, this cannot be solve without an extension as it is a very specific implementation of ODATA. In the meantime, I have set a condition to handle this implementation and will see later.
For second point, I am not enough skilled in Odata protocol to say what should be the correct behaviour. Perhaps examples below could help.
In all cases, pyodata raise a exception on trying to convert to a int a None Value
I do not see any side effect on trapping these 2 exceptions and doing nothing, perhaps it is the right thing to do.
**Case 1 and 2 : with 3 samples that raise this exception **
WARNING:pyodata.model:{'__metadata': {'type': 'Microsoft.Crm.Sdk.Data.Services.EntityReference'}, 'Id': 'f3d1cca6-0313-e711-80be-005056011e04', 'LogicalName': 'systemuser', 'Name': None}
WARNING:pyodata.model:{'__metadata': {'type': 'Microsoft.Crm.Sdk.Data.Services.EntityReference'}, 'Id': None, 'LogicalName': None, 'Name': None}
comes from these samples which there is no "Value" tag :
** case 3: is rather the same, but Value is explicitly set to Null **
filak-sap commentedon Apr 22, 2020
I am afraid that the None/null issue is a bug on pyodata.
https://www.odata.org/documentation/odata-version-2-0/atom-format/
I have to find such a value in Microsoft's Northwind -> https://services.odata.org/V2/Northwind/Northwind.svc/
filak-sap commentedon Apr 22, 2020
@bip91 Can you re-post the XML responses in JSON here? Just add
?$format=jsonto the URL.Example:
The example URLs point the entityset which contains entities having values with null and pyodata can handle them without any problem:
the output is the following:
where the field
Regionholdsnull.filak-sap commentedon Apr 22, 2020
Can you change the lines:
to
and repost your results?
bip91 commentedon Apr 23, 2020
It is coming from this kind of values :
And content in json format :
model: set UTC timezone to DateTimes read rom JSON too
tree-wide: correctly handle null values
filak-sap commentedon Apr 29, 2020
@bip91 Do you think you can test my changes in PR: #100 It only fixes the problem with None.
model: set UTC timezone to DateTimes read rom JSON too
tree-wide: correctly handle null values
bip91 commentedon Apr 29, 2020
Now, I get this error on initializing schema :
So, I have no initialized context to execute the request.
Please find joined, metadata url provided by server (with some anonymization, I hope that I have not introduce some error with step) :
https://server.com/CRM/XRMServices/2011/OrganizationData.svc/$metadata
content :
$metadata.txt
I hope this could help.
filak-sap commentedon Apr 29, 2020
I cannot reproduce the problem. Didn't you touch this list:
https://github.com/SAP/python-pyodata/blob/master/pyodata/v2/model.py#L2441
filak-sap commentedon Apr 29, 2020
In my version of pyodata, the exception you got is raised at the line 2535 but in your case it's line 2451.
4 remaining items
tree-wide: correctly handle null values
model: set UTC timezone to DateTimes read rom JSON too
tree-wide: correctly handle null values
model: set UTC timezone to DateTimes read rom JSON too
tree-wide: correctly handle null values
phanak-sap commentedon May 5, 2020
After merging of #102 this issue seems to be ready to be closed.
@bip91 could you confirm that latest head 7972f31 works for you?
I will create release 1.5.0 soon.
filak-sap commentedon May 5, 2020
@bip91 It would help us if you create a new issue for the PATCH vs. MERGE request.
bip91 commentedon May 7, 2020
Latest head works perfectly, I have deployed it instead of my first workaround.
I have also isolated the part "MERGE in a vendor request" in #103
jfilak commentedon Jun 30, 2020
@bip91 I would not mind if you create a new factory method MS_CRM_client in the vendor module which would return pyodata client correctly configured.
bip91 commentedon Jun 30, 2020
Yes, of course.
I have built MSCRM vendor extension :
MSCRM.py.txt
This works for me with the following code :
The endpoint has changed on more recent Dynamics CRM so the test on URL should be sufficient to avoid mistakes, but I cannot validate this (I have only Dynamics CRM 2015)
Feel free to adjust my extension to be coherent with the others.
model: set UTC timezone to DateTimes read rom JSON too
phanak-sap commentedon Aug 8, 2026
Hi @bip91 I trying to make sense of this after years, it seems to me that everything requested was done in related PRs and documentation changes.
If there is some specific issue with MS CRM 2015 and pyodata >1.12.0, please create a new one.