Create a simple script in Maximo and Call the Maximo Rest API request to post/get the data.
Let's create a simple automation script, it will create an SR with minimal information.
1. create a script in automation script application with below code:
from psdi.server import MXServer;srSet = MXServer.getMXServer().getMboSet("SR", MXServer.getMXServer().getSystemUserInfo());newSR = srSet.add();newSR.setValue("TICKETID", request.getQueryParam("ticketid"));
newSR.setValue("DESCRIPTION", request.getQueryParam("description"));srSet.save();
2. Now send below request from Postman or any other tool:
http://localhost/maximo/oslc/script/createjsonsr?_lid=maxadmin&_lpwd=maxadmin&ticketid=123&description=test ticket
or We also can send the data in payload
POST http://localhost/maximo/oslc/script/createjsonsr
MAXAUTH <encoded 64bit>
{"ticketid" : "123456","siteid" : "BEDFORD","description" : "test SR from http call"}
parameter appended in query string after (?)
request.getQueryParam("variable")
To get the user info from the request
request.getUserInfo()
read and parse the request to get the payload.
res = JSONObject.parse(output)
vId = res.get("id")
mbo.setValue("description",vId)
Hi Abdul, This solution is quite good. I try to copy your script then change SR to DOCLINKS to import a attachment file, the physical file is put on \doclinks\attachements already. REST post is executed return '1', but doclinks is empty. Do you have a sample script to import attachment?
ReplyDelete