The Business Case:
You have just gotten your FDMEE data loads set up and running, including DataMaps that are dynamic based on the hierarchies (i.e. if the level 0 member value is a descendant of a given parent map it, otherwise IGNORE). You discover the handy “Refresh Members” button on an FDMEE target application:
…but, as the administrator, you don’t want to have to log into the system and click that button once a day, every other day, or every hour.
Oracle doesn’t give you an any way to schedule this “Refresh Members” function, because why would you ever want to automate that? Right?! …Sigh…
…and here comes the FDMEE REST API to the rescue!!
Now, I had been mulling over this particular question for nearly a year, and finally came back to it in the last couple of weeks after I ran across this Refresh Members thread in the Oracle community where John Goodwin put an example REST post for refreshing the members. If you want a lot of great information regarding REST and PBCS, John has several great blog posts on the subject…
So, armed with this new information, I set out to find a way to write the jython script to submit the REST request. After digging around some python documentation, I did the right kind of search and came across one of Francisco’s REST API posts. As always, he provided some great codes snippets to pretty much write the entire script (Using On-Prem Planning REST API to Import Metadata). Of course, we aren’t using Planning, but we get a very good idea of how the script needs to go…
I’ll just pause here to say a huge “THANK YOU!” to these guys. They have helped me so much with their insight and knowledge!
A lot of the following will be very close to Francisco’s post, with a couple of changes.
Steps to run the “REFRESH MEMBERS” Job
1. Import modules:
Note the first import for DwgObject, which is another gift from Franciso. In one of his other blogs he talked about how to decode passwords from the ODI repository, so I have created a dummy data server in ODI to house my credentials to use for the authentication step, rather than a hardcoded UID and password.
2. Establish variables and build the REST URL:
3. Set up the “Payload” or “Data” for the request:
This is where I had some fun trying to figure out what was going on. All the information seemed to indicate that the “urllib.urlencode()” was required. However, I continued to receive a HTTP Error 400 – Incorrect Syntax error until I just passed the raw payload string. Once I commented out the urlencode line, voalà! Job submitted successfully!
4. Set the Authentication. Again, I use the method of decoding credentials from ODI for this.
5. Open the Request, add the Headers, and add the payload
There are a couple of methods for adding the payload/data and therefore causing the request to be a POST request. The following seemed nice and clean:
The debug log entries for the request objects were very helpful in diagnosing my issues with getting the script to work properly. The response may be parsed for different information like ProcessID and Status of the request. Based on the status, the sky is the limit on where to go next. You could even make this into a custom function to call from the BefImport event.
Hooray! A working “REFRESH MEMBERS” jython script utilizing the REST API for FDMEE! Hope this is helpful to you and good luck!