SAP / python-pyodata

Enterprise-ready Python OData client
Apache License 2.0
219 stars 93 forks source link

Help - effective dated data #86

Closed jacksonm1234 closed 4 years ago

jacksonm1234 commented 4 years ago

Hello, I'm hoping someone can help me. I've having an issue with Pyodata and using it to pull effective-dated Position entries from SAP SuccessFactors. For example, I'd like to be able to say give me all Position entries since 12/31/2018 for position '1795.' In my case it should return 3 entries, one effective 1/15/2019, one effective 12/8/2019, and one effective 3/14/2020. The data on each row may be slightly different depending on what was changed on those dates.

With a REST client called Postman, I successfully get the three expected entries using the following URL: "https://xxx.successfactors.com/odata/v2/Position?$filter=code+eq+'1795'&fromDate=2018-12-31"

Unfortunately, I can't get the same result from PyOData, no matter what I do. I'm able to get the latest entry without issue, but once I start specifying dates, it still only seems to pull the latest entry. I've tried an embarrassing number of variations on the code below, but I still can't seem to get it to work.

SERVICE_URL = "https://xxx.successfactors.com/odata/v2 session = requests.Session() session.auth = ('xxx', 'xxx') mySF = pyodata.Client(SERVICE_URL, session) myRequest = mySF.entity_sets.Position.get_entities().filter("code eq '1795' and fromDate=2018-12-31").execute()

Things I've tried:

At any rate, I'm about to give up. Pyodata could really be useful for some additional SF reporting, but only if I can get access to effective dated rows. Any ideas that I could try?

filak-sap commented 4 years ago

Hi @jacksonm1234, thank you for taking the time to report this issue.

Can you please share with us the following:

filak-sap commented 4 years ago

Asked also for help on SF colleagues. We will make it!

filak-sap commented 4 years ago

Since it seems to me that the parameter fromDate is not a part of the service, you can try this:

myRequest = mySF.entity_sets.Position.get_entities().filter("code eq '1795'").custom('fromDate', '2018-12-31').execute()
jacksonm1234 commented 4 years ago

The custom command WORKED! I get the expected three results. Wow, that was easy. Thank you very much!

One last question, does pyOdata have an easy way to extract the data from each entity, perhaps into a dictionary, or even a pandas DataFrame?

filak-sap commented 4 years ago

Hi @jacksonm1234, I would like to close this issue to keep one problem per issue. I am not aware of any pandas integration, though, there was a user who has sent me a sample code transforming pyodata responses to panda DataFrame, but I am not sure if I can publish his code sample. Please, open a new issue for this and will try to add my own solution.