IBM Business Process Manager


REST API


Hi All,
I am trying to use GetData function in RESTAPI ,But i am trying to retreive the value of a variable which is present in complex vaiable.
Example:requisition is a complex object having reqNum as variable.I am using rest api tester
How to get varaible value of complex object?
This is sample code I have for jQuery. You'll see that you only provide the name of the variable on the service, not any references to properties inside it (a major limitation IMO).
Below will make the call to the URL (assuming you're running it from same domain as the BPM server). The success callback is where you'll be able access the data.
$.ajax({
url: '/rest/bpm/wle/v1/service/' + taskId + '?action=getData&fields=requisition',
success: function(res) {
if (res.status === '200') {
var data = res.data.resultMap;
data.requisition.reqNum // this is what you want
} else {
console.error('request for task ' + taskId);
}
}
});
Hi Chirsja,
If you just want to check the value in REST API tester, then in fields section you can type only the base object/variable name.
i.e. you can write as tw.local.requisition or requisition
and not tw.local.requisition.reqNum or requisition.reqNum.
Also, verify if you are using task ID there.
Thanks,
Kiran
G2AE_Kiran_Deorukhkar
270005G2AE
‏2014-08-09T15:25:16Z
Hi Chirsja,
If you just want to check the value in REST API tester, then in fields section you can type only the base object/variable name.
i.e. you can write as tw.local.requisition or requisition
and not tw.local.requisition.reqNum or requisition.reqNum.
Also, verify if you are using task ID there.
Thanks,
Kiran
More...
Thanks Kiran
Samuel Chan
270005XWSX
‏2014-08-09T11:41:11Z
This is sample code I have for jQuery. You'll see that you only provide the name of the variable on the service, not any references to properties inside it (a major limitation IMO).
Below will make the call to the URL (assuming you're running it from same domain as the BPM server). The success callback is where you'll be able access the data.
$.ajax({
url: '/rest/bpm/wle/v1/service/' + taskId + '?action=getData&fields=requisition',
success: function(res) {
if (res.status === '200') {
var data = res.data.resultMap;
data.requisition.reqNum // this is what you want
} else {
console.error('request for task ' + taskId);
}
}
});
More...
Thanks for giving code samuel
Samuel Chan
270005XWSX
‏2014-08-09T11:41:11Z
This is sample code I have for jQuery. You'll see that you only provide the name of the variable on the service, not any references to properties inside it (a major limitation IMO).
Below will make the call to the URL (assuming you're running it from same domain as the BPM server). The success callback is where you'll be able access the data.
$.ajax({
url: '/rest/bpm/wle/v1/service/' + taskId + '?action=getData&fields=requisition',
success: function(res) {
if (res.status === '200') {
var data = res.data.resultMap;
data.requisition.reqNum // this is what you want
} else {
console.error('request for task ' + taskId);
}
}
});
More...
Hi Samuel,
Thank you for providing the JQuery code. Could you also provide Ajax properties settings to login BPM server.
I have the following Ajax in Javascript but the server responds with error.
$.ajax({
url: 'https://host:port/rest/bpm/wle/v1/search/query?organization=byInstance&filterByCurrentUser=false&size=10',
type: 'PUT',
dataType: 'jsonp',
contentType: "application/x-www-form-urlencoded",
username: "admin",
password: "admin",
Accept: "application/json",
headers: { 'Access-Control-Allow-Origin': '*' },
xhrFields: {
withCredentials: true
}
}).success(function(data) {
console.log(data)
$('#output').html(data);
}).error(function(xhr, status, error) {
alert("error");
console.log(xhr);
});
The error code: GET https://host:port/rest/bpm/wle/v1/search/query?organi…size=10&callback=jQuery110101883550228085369_1408050480505&_=1408050480506 405 (Method Not Allowed)
By changing dataType: 'jsonp' to 'json', the server responds with the following error:
XMLHttpRequest cannot load https://host:port/rest/bpm/wle/v1/search/query?organization=byInstance&filterByCurrentUser=false&size=10. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
RC6M_Shiwa_Fu
270002RC6M
‏2014-08-14T21:12:19Z
Hi Samuel,
Thank you for providing the JQuery code. Could you also provide Ajax properties settings to login BPM server.
I have the following Ajax in Javascript but the server responds with error.
$.ajax({
url: 'https://host:port/rest/bpm/wle/v1/search/query?organization=byInstance&filterByCurrentUser=false&size=10',
type: 'PUT',
dataType: 'jsonp',
contentType: "application/x-www-form-urlencoded",
username: "admin",
password: "admin",
Accept: "application/json",
headers: { 'Access-Control-Allow-Origin': '*' },
xhrFields: {
withCredentials: true
}
}).success(function(data) {
console.log(data)
$('#output').html(data);
}).error(function(xhr, status, error) {
alert("error");
console.log(xhr);
});
The error code: GET https://host:port/rest/bpm/wle/v1/search/query?organi…size=10&callback=jQuery110101883550228085369_1408050480505&_=1408050480506 405 (Method Not Allowed)
By changing dataType: 'jsonp' to 'json', the server responds with the following error:
XMLHttpRequest cannot load https://host:port/rest/bpm/wle/v1/search/query?organization=byInstance&filterByCurrentUser=false&size=10. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
More...
I have to ask: you replaced your real host and real port with just 'host' and 'port', right?
Next question: you can only run AJAX calls from the same domain as the host. Cross-domain requests have to be explicitly allowed on the server (hence the second error message).
And generally, why aren't you already logged in to that domain? Who would be running code against the server and isn't already authenticated? You're putting the password in plain text. If this is a developer/internal only tool, then you should already be logged in.
Samuel Chan
270005XWSX
‏2014-08-15T00:46:56Z
I have to ask: you replaced your real host and real port with just 'host' and 'port', right?
Next question: you can only run AJAX calls from the same domain as the host. Cross-domain requests have to be explicitly allowed on the server (hence the second error message).
And generally, why aren't you already logged in to that domain? Who would be running code against the server and isn't already authenticated? You're putting the password in plain text. If this is a developer/internal only tool, then you should already be logged in.
More...
1. Yes. replaced.
2. different domain from the server
3. putting password just for testing purpose, not real code.
Any way to make the above code workable?
We have BPM 8.5 (not 8.5.5). As BPM 8.5 REST API Tester does not have the option filterByCurrentUser, I just want to test, using Ajax, if BPM 8.5 support this option.
Using Browser with the URL (https://host:port/rest/bpm/wle/v1/search/query?organization=byInstance&filterByCurrentUser=false&size=10) does not return any result.
I saw your postings related to the above topic in another posting thread.
Could you confirm if BPM 8.5 support the above option ( filterByCurrentUser). Thanks.
RC6M_Shiwa_Fu
270002RC6M
‏2014-08-14T21:12:19Z
Hi Samuel,
Thank you for providing the JQuery code. Could you also provide Ajax properties settings to login BPM server.
I have the following Ajax in Javascript but the server responds with error.
$.ajax({
url: 'https://host:port/rest/bpm/wle/v1/search/query?organization=byInstance&filterByCurrentUser=false&size=10',
type: 'PUT',
dataType: 'jsonp',
contentType: "application/x-www-form-urlencoded",
username: "admin",
password: "admin",
Accept: "application/json",
headers: { 'Access-Control-Allow-Origin': '*' },
xhrFields: {
withCredentials: true
}
}).success(function(data) {
console.log(data)
$('#output').html(data);
}).error(function(xhr, status, error) {
alert("error");
console.log(xhr);
});
The error code: GET https://host:port/rest/bpm/wle/v1/search/query?organi…size=10&callback=jQuery110101883550228085369_1408050480505&_=1408050480506 405 (Method Not Allowed)
By changing dataType: 'jsonp' to 'json', the server responds with the following error:
XMLHttpRequest cannot load https://host:port/rest/bpm/wle/v1/search/query?organization=byInstance&filterByCurrentUser=false&size=10. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
More...
Hi folks,
Does anyone know how to modify the Access-Control-Allow-Origin attribute for BPM ?
Thanks!
Edourd
RC6M_Shiwa_Fu
270002RC6M
‏2014-08-15T01:17:26Z
1. Yes. replaced.
2. different domain from the server
3. putting password just for testing purpose, not real code.
Any way to make the above code workable?
We have BPM 8.5 (not 8.5.5). As BPM 8.5 REST API Tester does not have the option filterByCurrentUser, I just want to test, using Ajax, if BPM 8.5 support this option.
Using Browser with the URL (https://host:port/rest/bpm/wle/v1/search/query?organization=byInstance&filterByCurrentUser=false&size=10) does not return any result.
I saw your postings related to the above topic in another posting thread.
Could you confirm if BPM 8.5 support the above option ( filterByCurrentUser). Thanks.
More...
I think you are in luck - I posted a BPM REST sample a while back. The sample shows an approach to making REST calls from within BPM itself. I know that's not the stated goal, but my sample is based on BPM 8.5 and it exercises the same BPM REST API being referenced here (Process/Task query is a popular one). The Ajax is abstracted away (using Kolban's Toolkit) and it comes with a nice UI front end. You should be able to tweak the URL being passed in within the BPD and test things out. You'll see how the JSON response data is parsed and since it runs within BPM, you won't run into any same origin policy issues.
https://hub.jazz.net/project/spcommunity/bpm-search-server-side-rest/overview
Click the download icon to get the contents as a zip file and take a look at the PDF within.

Related Links

Users unable to log into ProcessPortal using Chrome - SESN0008E
Automating Role Generation and Population
Custom Security in WLE 7.2
Unable to customize the Process Portal - WebDav Error
[IBPM 8.0.1] UCA random behavior ... urgent question
IBM BPM 8.5
Task Narrative
Getting selected row on a table
AJAX service needs a String and a Complex Type as input
Beginner: What\'s the difference between Process Designer and Integration Designer?
Coach Views - Subscribe to an event from a subview
Start an ad-hoc task/event when there is no open task in my inbox
Instance Create Date
How to use BPM variables in custom HTML
A good example to convert JSON into twObject
Forum Post Doesn\'t work except IE

Categories

DW
Tivoli Netcool/Impact
Unica
IBM TRIRIGA
Developer Central
dwjapan
test
Globalization
C/C++ compilers for IB...
IBM Connections Cloud ...
IBM Verse
IBM Kenexa Talent Mana...
zSecure suite
IBM Security Identity ...
Marketing Platform
Facilities Maintenance...
Environmental and Ener...
Jazz for Service Manag...
IBM Tivoli Monitoring ...
Security Configuration...
IBM SPSS Statistics Ge...
R Programmability in S...
.NET Programmability
RDz - Rational Develop...
EGL Cafe
WebSphere ILOG Busines...
Development Tools (RAD...
Rational Application D...
wireless
university
rational
Wireless
dW Questions and Answers
Optim LUW
IBM Data Studio
Objrepos - AIX ユーザー・コミ...
IBM Toolbox for Java a...
IBM Forms Experience B...
For All Type Post
IBM PureData-Enzee Com...
Part 3 - Challenge #14...
IBM Integration Design...
WebSphere eXtreme Scale
IBM Security Identity ...
IBM Security Identity ...
Collecting Windows Eve...
QRadar Incident Forens...
Investigating with QRadar
Web Services
General Discussions
IBM Control Center
Managed File Transfer
Applications Q & A
Learning @ Sterling Co...
Warehouse Management
Multi-Channel Fullfill...
Gentran Server for AS/400
Connect:Direct for Win...
Connect:Direct for UNIX
Connect:Enterprise Mai...
Selling System SDK
Selling System Release...
C3 Product Manager/C3 ...
C3 Replenishment
SDK Tools & Utilities
C3 Partner.com/C3 Stor...
Back End Integation
Platform Issues
Commerce/Order Management
Receipts
Product Management
Call Center Order Mana...
Service Definition Fra...
Interoperability
Extensibility
App Servers
IBM z Systems Developm...
Business Rules Best Pr...
General BRMS Discussion
Radar charts
CP Optimizer
OPL using CPLEX Optimizer
Форум по AIX и UNIX
Форум IBM developerWor...
Tivoli Application Dep...
OMEGAMON Performance M...
IBM SmartCloud Cost Ma...
System x Server
Lotus Web Content Mana...
Lotus ActiveInsight an...
XML and Java Technology
Working XML forum

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile