Original Message:
Sent: 12-30-2025 14:47
From: Jose Nodeland
Subject: Post linked document to MAS
We use rest for some items, where it works. I've problems with Maximo rest because a lot of the documentation is wrong, incomplete or vague, and samples that do not work. And when things do not work, it's a black box that is difficult to troubleshoot.
------------------------
Example of wrong documentation, all the docs use GET /oslc/os/mxapiasset, which does not work for mas (at least does not work for us), one has to use api/os not oslc/os.
-------------------------------
Example of vague documentation, "https://ibm-maximo-dev.github.io/maximo-restapi-documentation/attachment/attachment/" says "
- Enable the attachments feature.", what is that supposed to mean. Basic out of the box doclinks configuration or??
----------------------------
Example of a "black box" error, the first example at https://ibm-maximo-dev.github.io/maximo-restapi-documentation/crud/create_and_update
says:
POST /oslc/os/mxapiasset
Post body:
{ "assetnum": "ASSET1", "siteid": "BEDFORD", "description": "my first asset" }
Using postman to perform the post (after changing the url to api/os), the following error is thrown "Site id cannot be null". Makes no sense to us why that error is thrown, siteid has been supplied.
--------------------------------------------
I can give many such samples. Eventually we quit wasting time trying to figure out the rest black box and try something else.
------------------------------
Jose Nodeland
JedaWorks
Original Message:
Sent: 12-29-2025 10:42
From: Steven Shull
Subject: Post linked document to MAS
The REST API in Maximo is extremely powerful and can handle almost any scenario, including this. Please look at utilizing that (IBM Maximo REST API Guide – Handling Attachments) rather than trying to process the message yourself. The REST API provides error handling, validation (assetnum ABC123 is not valid), actions (setting attribute A should set attribute B), security controls (restricting field access), processing (attachments can be stored as files on a file system, S3, Azure, or custom adapters like SharePoint and you need different handling for each), etc.
If you want, you can use the exclude attributes feature on the object structure you create to only enable the subset of fields you want to be set on the SR.
------------------------------
Steven Shull
Naviam
Original Message:
Sent: 12-27-2025 16:47
From: Jose Nodeland
Subject: Post linked document to MAS
Perhaps someone has a working example of posting a linked doc via a rest call to MAS.
I've tried this approach, it's creating the link, but when viewing the record and the linked docs, viewing the document fails with an error. We are not stuck with using this approach, it's just a best guess attempt. Other approaches are welcome.
Postman is posting to url
https://myserver/maximo/api/script/SERVICEREQUESTADD
the following json (note documentdata is a base64 encoded string)
{
"REPORTEDBY": "71311461F",
"REPORTEDBYID": "71311461F",
"REPORTEDEMAIL": "abc@def.com",
"REPORTEDPHONE": "1234567",
"DESCRIPTION": "Testing",
"DESCRIPTION_LONGDESCRIPTION": "long description",
"ASSETORGID": "EAGLENA",
"ASSETSITEID": "MYSITE",
"ORGID": "EAGLENA",
"SITEID": "MYSITE",
"LOCATION": "Z95",
"DOCLINKS": [
{
"DOCUMENT": "test.txt",
"DESCRIPTION": "File added by rest post",
"URLTYPE": "FILE",
"DOCTYPE": "Attachments",
"ADDINFO": "1",
"SHOW": "1",
"PRINTTHRULINK": "0",
"URLNAME": "test.txt",
"DOCUMENTDATA": "MTIzNHRlc3Qy"
}
]
}
******************************************************************************
And this is the SERVICEREQUESTADD script. As mentioned, the SR is created, the linked doc record is created, but the file cannot be viewed using the Maximo "View Linked Docs" UI feature.
# MAS 9 REST Automation Script
# Accepts JSON, creates SR, logs processing, returns SR number or error
from psdi.server import MXServer
from psdi.mbo import MboConstants
from java.util import Base64
from java.io import ByteArrayInputStream
from java.lang import Exception as JavaException
from com.ibm.json.java import JSONObject, JSONArray
mxServer = MXServer.getMXServer()
responseBody = "{}"
try:
service.log_info("CREATE_SR_REST: Script execution started")
if not requestBody:
service.log_info("CREATE_SR_REST: No JSON payload received")
raise Exception("No JSON payload provided")
service.log_info("CREATE_SR_REST: Raw requestBody = " + str(requestBody))
data = JSONObject.parse(requestBody)
service.log_info("CREATE_SR_REST: JSON parsed successfully using IBM JSONObject")
userInfo = mxServer.getSystemUserInfo()
srSet = mxServer.getMboSet("SR", userInfo)
sr = srSet.add()
service.log_info("CREATE_SR_REST: SR MBO created")
fields = [
""REPORTEDBY","REPORTEDBYID","REPORTEDEMAIL","REPORTEDPHONE",
"DESCRIPTION","DESCRIPTION_LONGDESCRIPTION","AFFECTEDPERSON",
"AFFECTEDPERSONID","ASSETORGID","ASSETSITEID",
"ORGID","SITEID","LOCATION"
]
for f in fields:
if data.containsKey(f):
val = data[f]
if val is not None and str(val) != "":
sr.setValue(f, str(val), 11)
# ---------------------------------------------------------------------
# Process Attachments
# ---------------------------------------------------------------------
if data.containsKey("DOCLINKS"):
docSet = sr.getMboSet("DOCLINKS")
docArray = data.get("DOCLINKS")
for d in docArray:
filename = d.get("DOCUMENT")
description = d.get("DESCRIPTION")
filedata = d.get("DOCUMENTDATA")
service.log_info(">>> Attaching file: " + filename)
# Decode Base64
bytesData = Base64.getDecoder().decode(filedata)
#stream = ByteArrayInputStream(bytesData)
document = d.get("DOCUMENT")
description = d.get("DESCRIPTION")
urltype = d.get("URLTYPE")
doctype = d.get("DOCTYPE")
urlname = d.get("URLNAME")
filedata = d.get("DOCUMENTDATA")
service.log_info(">>> Processing attachment: " + document)
doc = docSet.add()
doc.setValue("ADDINFO",1)
doc.setValue("DOCUMENT", document)
doc.setValue("DESCRIPTION", description)
doc.setValue("URLTYPE", urltype)
doc.setValue("DOCTYPE", doctype)
doc.setValue("URLNAME", urlname)
doc.setValue("NEWURLNAME", urlname)
doc.setValue("DOCUMENTDATA", filedata)
service.log_info("Saving SR " + sr.getString("TICKETID"))
srSet.save()
sr_num = sr.getString("TICKETID")
service.log_info("CREATE_SR_REST: SR saved successfully: " + sr_num)
responseBody = (
'{"status":"SUCCESS","sr_number":"' + sr_num + '"}'
)
except JavaException as je:
msg = str(je)
service.log_info("CREATE_SR_REST: JavaException occurred: " + msg)
responseBody = '{"status":"ERROR","message":"' + msg + '"}'
except Exception as e:
msg = str(e)
service.log_info("CREATE_SR_REST: Exception occurred: " + msg)
responseBody = '{"status":"ERROR","message":"' + msg + '"}'
service.log_info("CREATE_SR_REST: Script completed")
#Integrations
#MaximoApplicationSuite
------------------------------
Jose Nodeland
JedaWorks
------------------------------