Hi Lusheng. Do you have a specific question?
Have you read the WebFOCUS manual "WebFOCUS Embedded Business Intelligence User's Guide Release 8.2 Version 03" available at
https://webfocusinfocenter.inf...dded_bi_user8203.pdf ? It has examples in JavaScript.
I have experience using the REST API with Python. I will be posting my code, a Python wrapper for many of the WF REST calls, to GitHub in the next month or so.
A good module for making HTTP (REST) requests will handle putting the HTTP header and body together. Python's Requests library (http://docs.python-requests.org/en/master/) and JavaScript Request (https://github.com/request/request) are both relatively easy to use.
Here is an example (prompted by Waz) to run an ad hoc fex and return JSON. And I highly recommend using Fiddler for debugging REST calls (https://www.telerik.com/fiddler)
URL:
http://localhost:8080/ibi_apps/rs/ibfs/EDAHeader: {'User-Agent': 'python-requests/2.18.4', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Cookie': 'WF-JSESSIONID=12E4A798EE2EAF81232EC5A5884471D5', 'Content-Length': '248', 'Content-Type': 'application/x-www-form-urlencoded'}
Body (manually formatted):
IBIRS_action=runAdHocFex &
IBIRS_path=EDA &
IBIRS_nodeName=EDASERVE &
IBIRS_fexContent=TABLE+FILE+CAR%0APRINT+%0A++MPG%0A++SEATS%0ABY+COUNTRY%0ABY+CAR%0ABY+MODEL%0AON+TABLE+PCHOLD+FORMAT+JSON%0AEND%0A&IBIWF_SES_AUTH_TOKEN=f149ec78dfcced2f9eb2520af06ebd7b
The ad hoc (inline) fex is:
TABLE FILE CAR
PRINT
MPG
SEATS
BY COUNTRY
BY CAR
BY MODEL
ON TABLE PCHOLD FORMAT JSON
END
Results:
{"records" : [{"COUNTRY" : "ENGLAND","CAR" : "JAGUAR","MODEL" : "V12XKE AUTO","MPG" : 16,"SEATS" : 2},{"COUNTRY" : "ENGLAND","CAR" : "JAGUAR","MODEL" : "XJ12L AUTO","MPG" : 9,"SEATS" : 5},{"COUNTRY" : "ENGLAND","CAR" : "JENSEN","MODEL" : "INTERCEPTOR III","MPG" : 11,"SEATS" : 4},{"COUNTRY" : "ENGLAND","CAR" : "TRIUMPH","MODEL" : "TR7","MPG" : 25,"SEATS" : 2},{"COUNTRY" : "FRANCE","CAR" : "PEUGEOT","MODEL" : "504 4 DOOR","MPG" : 21,"SEATS" : 5},{"COUNTRY" : "ITALY","CAR" : "ALFA ROMEO","MODEL" : "2000 4 DOOR BERLINA","MPG" : 21,"SEATS" : 4},{"COUNTRY" : "ITALY","CAR" : "ALFA ROMEO","MODEL" : "2000 GT VELOCE","MPG" : 21,"SEATS" : 2},{"COUNTRY" : "ITALY","CAR" : "ALFA ROMEO","MODEL" : "2000 SPIDER VELOCE","MPG" : 21,"SEATS" : 2},{"COUNTRY" : "ITALY","CAR" : "MASERATI","MODEL" : "DORA 2 DOOR","MPG" : 0,"SEATS" : 2},{"COUNTRY" : "JAPAN","CAR" : "DATSUN","MODEL" : "B210 2 DOOR AUTO","MPG" : 0,"SEATS" : 4},{"COUNTRY" : "JAPAN","CAR" : "TOYOTA","MODEL" : "COROLLA 4 DOOR DIX AUTO","MPG" : 27,"SEATS" : 4},{"COUNTRY" : "W GERMANY","CAR" : "AUDI","MODEL" : "100 LS 2 DOOR AUTO","MPG" : 23,"SEATS" : 5},{"COUNTRY" : "W GERMANY","CAR" : "BMW","MODEL" : "2002 2 DOOR","MPG" : 24,"SEATS" : 5},{"COUNTRY" : "W GERMANY","CAR" : "BMW","MODEL" : "2002 2 DOOR AUTO","MPG" : 24,"SEATS" : 4},{"COUNTRY" : "W GERMANY","CAR" : "BMW","MODEL" : "3.0 SI 4 DOOR","MPG" : 18,"SEATS" : 5},{"COUNTRY" : "W GERMANY","CAR" : "BMW","MODEL" : "3.0 SI 4 DOOR AUTO","MPG" : 18,"SEATS" : 5},{"COUNTRY" : "W GERMANY","CAR" : "BMW","MODEL" : "530I 4 DOOR","MPG" : 18,"SEATS" : 5},{"COUNTRY" : "W GERMANY","CAR" : "BMW","MODEL" : "530I 4 DOOR AUTO","MPG" : 18,"SEATS" : 5}]}
Python source code (using Requests) module:
def rs_run_ad_hoc_fex(self, nodename='EDASERVE', fex_content=''):
"""Reporting Server: Running a Report Within an Application."""
method = 'post'
data = {
'IBIRS_action': 'runAdHocFex',
'IBIRS_path': 'EDA',
'IBIRS_nodeName': nodename,
'IBIRS_fexContent': fex_content
}
url = '{}://{}:{}/ibi_apps/rs/ibfs/EDA'.format(self.protocol,
self.host,
self.port)
# add the CSRF token value to the body (data) of the request
if self.IBIWF_SES_AUTH_TOKEN is not None:
data['IBIWF_SES_AUTH_TOKEN'] = self.IBIWF_SES_AUTH_TOKEN
return self.request(method=method, url=url, data=data)
Prior to making the REST call, the user or calling program must sign on and also get session authorization token to use in subsequent calls.