IBM Maximo : Upload docklinks attachments using REST API
In this post I will explain in details how to upload attachments to Maximo record using REST API.
I will be using Work Order to explain this use case.
First step is to configure Object Strcture having required objects as in this case WorkOrder and DOCLINK
I have created Object Strcture as below :
Object Structure : RESTWODOCLINKS
Description : Upload WO Attachment using REST API
Its consumed by Integration and includes Workorder and DOCLINKS objects.
Next step is to configure security for Object Structure to grant access to specific groups which is being used by REST API call user.
You can refer my other post IBM Maximo REST API Example - Change Person/User/Labor status for the same.
If you miss to configure object structure for respective group you might get error like below :
Next we are going to submit REST request , I will be using Postman client for the same and detailed explanation of postman parameters and rest/oslc URLs is explained in my post here @ IBM Maximo REST API Example - Change Person/User/Labor status .
I have created sample RESTTEST Workorder to be used in this example.
This record can be fetched with REST URI as below sample URI format is
http://host:port/maximo/oslc/os/RESTWODOCLINKS/_QkVERk9SRC9SRVNUVEVTVA--?lean=1
Now I am going POST REST call using Postman client.
I am using sample JSON paylod as below to upload attachment against Workorder :
Postman sample POST request URL is http://host:port/maximo/oslc/os/RESTWODOCLINKS/_QkVERk9SRC9SRVNUVEVTVA--?lean=1
{
"wonum": "RESTTEST",
"siteid": "BEDFORD",
"orgid": "EAGLENA",
"doclinks":[
{
"ADDINFO": "1",
"COPYLINKTOWO": "0",
"DESCRIPTION": "Example Attachment via REST API",
"DOCUMENT": "Test via Rest API",
"OWNERTABLE": "WORKORDER",
"UPLOAD": "1",
"NEWURLNAME": "www.ibm.com",
"urltype":"FILE",
"documentdata":"aGV5IGhvdyBhcmUgeW91",
"doctype":"Attachments",
"urlname":"SampleREST-Upload.txt",
"OWNERID" : "133634"
}
]
}
This POST request then successfully adds Attachment against workorder :
If you want to achieve same thing using Web Service you can refer IBM blog @ IBM Maximo: Iimport attachments into MAXIMO using MIF Web Services.
Additionally IBM REST API Guide can be referred @ IBM Maximo REST API Guide