How to access xCP stateless process resource through REST webservice
I have access one of my xCP 2.1 project stateless process resource through REST webservice.
{
- "id": "types/processes.json/xcp_getfolderid",
- "title": "xcp_getfolderid",
- "summary": "get Folder Id From Folder Path",
- "updated": "2014-05-26T08:03:35.765-04:00",
- "content": {
- "content-type": "application/vnd.emc.xcp+json",
- "src": "types/processes.json/xcp_getfolderid"
- "links": [
- {
- "rel": "self",
- "href": "types/processes.json/xcp_getfolderid"
- {
}
where the process needs input parameters as folder path/name/type/id.
How to pass the input parameters to below URL http://****.****.com:8080/MYAPP/types/processes.json/xcp_getfolderid to get the folder id response.
Right now I am getting error as
<dm:error><dm:status>404</dm:status><dm:code>E_RESOURCE_NOT_FOUND</dm:code><dm:message>Operation on object failed because the specified resource by ID, name, type or path is not found</dm:message><dm:details/></dm:error>
Thanks,
Srini
Comments
-
Hi Srini,
You are trying to start the stateless process by calling the definition of the process; note the 'types' entry in your URL.
You should try a POST to the instances URL:
http://****.****.com:8080/MYAPP/processes/xcp_getfolderid
The JSON body:
{ "run-stateless" : "true",
"data" : {
"variables" : {
"folder_path" : "/Temp"
}
}
}
Good luck!
Cheers,
Sandor
0 -
Hey Sandor,
Trying to call an SP from another SP using Send HTTP/RESTful request. Have you seen any examples on how to do this?
Cheers Niall
0 -
Hello Niall,
Why would you do this, if you can just call a stateless process using the "Call Stateless Process" activity.
Friendly Regards,
Koen Verheyen.
0 -
To call an SP in another xCP app.
Niall
0 -
Apparently there is a REST API generated for SP’s in xCP2.1, however I can't find any info on how to call them, other than this post.
I forgot that most of the Netherlands will be on holiday so probably won't get anything from Sandor on this.
Niall
0 -
One can share Stateless Processes over applications by using projects.
0 -
That's not what I want. I want to be able to deploy mini-xCP apps that contain sets of services that are consumed at run-time by other xCP apps.
Niall.
0 -
Even in that case, you can use sub-projects and call the stateless process across applications. After all stateless processes are normal REST services, you can very well use JSON libraries in your java module (assuming you are using java services) and call the stateless processes. However authorization would be a challenge if you want to use completely different applications.
0 -
Yes - but I don't want the tight coupling between the projects.
http(s)://<host>:<port>//<your app>/processes/<your process name> or for a specific instance
http(s)://<host>:<port>//<your app>/processes/<your process name>/<r_object_id>
JSON request is constructed in the following format:
{
"name" : "process",
"type" : "<your process name>",
"run-stateless" : "true",
"data" : {
"variables": {
"<your int variable> : "3",
"<your string variable> : "String",
"<your multi-value var> : ["A","B","C"]
}
}
}
Authentication from another xCP process is OK (in most cases) because you can get a ticket and pass that through with the user name in the JSON.
Niall
0 -
following is the code we used (we used for Unit Testing and you can use the same for normal java as well). This will help you in passing parameters.
Libraries we used
import com.jayway.restassured.http.ContentType;
import org.junit.Test;
import static org.hamcrest.Matchers.hasItem;
private final static String GET_REQUEST = "/application/processes/" + "<process_name>";
private final static String INPUT_PARAM_TYPE = "type";
private final static String INPUT_PARAM_TYPE_VALUE = "xxxxxx_initiate_staless_ds";
private final static String OUTPUT_PARAM_ITEMS_DISPLAY = "items.display";
private final static String OUTPUT_PARAM_ITEMS_VALUE = "items.value";
private final static String OUTPUT_PARAM_ITEMS_DISPLAY_VALUE = "<value to be passed>";
private final static String OUTPUT_PARAM_ITEMS_VALUE_VALUE = "<value to be passed>";
@Test
public void getProjectContainers() {
request(true).
contentType(ContentType.JSON).
queryParam(INPUT_PARAM_TYPE, INPUT_PARAM_TYPE_VALUE).
expect().
contentType(ContentType.JSON).
body(OUTPUT_PARAM_ITEMS_DISPLAY, hasItem(OUTPUT_PARAM_ITEMS_DISPLAY_VALUE)).
body(OUTPUT_PARAM_ITEMS_VALUE, hasItem(OUTPUT_PARAM_ITEMS_VALUE_VALUE)).
statusCode(200).
when().
log().all(true).
get(GET_REQUEST);
//http://10.131.225.177:8000/<app_name>/application/processes
// /xxxx_containers_initiate?
// _dc=1373980393574&type=xxxxx_staless_ds
}0 -
Hi Niall,
Indeed, I was on Holidays!
You can use the send HTTP/RESTful Request activity to call other Stateless Process that are exposed as REST service.
Tips:
Use the POST prototcol
Don't use Multipart/Formdata
Make sure the Headings are mapped correctly (e.g. Authorization and Content-Type)
Map the JSON body as String-to-Byte
And of course, use the correct URL mapping.
This should work (it did for me).
Good luck!
Sandor
0 -
Hey Sandor - great to hear from you again.
That's exactly what I've done and it worked for me to.
Thanks for your help.
Niall
0 -
Hi Hari,
Thanks for your help and the code snippet. Although we didn't use your approach we will definitely be using it when calling out to other non-xCP services.
Excellent.
Cheers Niall
0 -
Hi Sandor,
I am getting 404 error when invoking the stateless process.
Could you please throw in more details?
What should be the values for
Header >
1. User- Agent
2. Content-Type
3. Content- Encoding
Body >
1. Content-Type
2. Data (For - string-to-byte what should be the 2nd parameter. Should it be 'UTF-8' or something else)
0
Categories
- All Categories
- 108 Developer Announcements
- 49 Articles
- 100 General Questions
- 122 IM Services
- 40 OpenText Hackathon
- 31 Developer Tools
- 20.6K Analytics
- 4.1K AppWorks
- 8.9K Extended ECM
- 897 Cloud Fax and Notifications
- 77 Digital Asset Management
- 9.3K Documentum
- 29 eDOCS
- 120 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management