Skip to Main Content

Analytics Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Using Jython for Essbase Cloud Service REST API Dataload

Craig MaxeyAug 27 2019 — edited Aug 28 2019

Hi all...first post here so hope this is acceptable. 

I’m trying to write a jython script in FDMEE to make a REST call to the Essbase cloud service for a streaming DataLoad.  I am successfully initiating the stream (I think) as I am getting a JSON response back with a streamID.  However, when I then send the next POST request to that streamID (including a comma delimited string as payload), I get back the response with an error code 400 and JSON including an error Message of ‘Stream id ‘123456’ does not exist’.  This is true of both the POST request to stream data and also the DELETE request to stop the stream.

I am using the urllib and urllib2 libraries in jython but have also tried httplib as well with similar results.

Question:  Does anyone have any experience with this particular REST API call?  I feel like I’m missing something very obvious. 

Applicable piece of Jython script:
baseURL='https://OACpath/essbase'
restEndPoint='rest/v1/applications/appapp/databases/cubecube/dataload'
restURL=r"%s/%s" % (baseURL,restEndPoint)

#Dictionary for request body
bodyDict = {}
bodyDict['ruleFileName'] = ‘rule_test'
PayLoad=JSONObject(bodyDict)
str_payload=str(PayLoad).encode('utf8')

request=urllib2.Request(restURL)
request.add_header('Authorization', authHeader)
request.add_header('Content-Type','application/json')
request.add_data(str_payload)

try:
  urlHandler=urllib2.urlopen(request)
  time.sleep(3)
  response = urlHandler.read()
except urllib2.HTTPError, e:
  fdmAPI.logInfo('code: %s, desc: %s' % (e.code,e.read()))
  fdmAPI.logIfno('full url: %s' % (request.get_full_url())) 

sid = string containing streamId parsed out of response from prev call.
newRestURL=r"%s/%s/%s" % (baseURL,restEndPoint,sid)
samp="comma delimited data"
request2=urllib2.Request(newRestURL)
request2.add_header('Authorization', authHeader)
request2.add_header('Content-Type','text/plain')
request2.add_data(samp)

try:
  urlHandler2=urllib2.urlopen(request2)
  response2= urlHandler2.read()
  fdmAPI.logDebug(response2)
except urllib2.HTTPError, e:
  fdmAPI.logInfo('code: %s, desc: %s' % (e.code,e.read()))
  fdmAPI.logInfo('full url: %s' % (request2.get_full_url()))
  fdmAPI.logInfo('headers: %s' % (request2.header_items()))

Comments