Generating a Work Order to MaintainX from Ignition?

Here's a preliminary first try at converting Postman to Ignition httpClient. Replace the token variable with your token. You can run this in the Script Console, at least to try it out.

The code
# Create the JythonHttpClient 
client = system.net.httpClient()

url = "https://api.getmaintainx.com/v1/workorders"
body = {
    "title": "Inspection of Water Pump #1 PN:111 (Pump House), Vibration Warning",
    "assetId": 5054334,
    "assignees": [
        {
            "id": 82364,
            "type": "TEAM"
        }
    ],
    "estimatedTime": 1800,
    "categories": [
        "Inspection",
        "Damage"
    ],
    "description": "Whenever irregularities in the water pump operation arise, our established procedure initiates a comprehensive inspection of the pump system in our facility. This encompasses assessing the condition of filters for timely replacement. Technicians conducting the inspection will sign off upon completion to facilitate tracking of maintenance activities.",
    "locationId": 1921018,
    "priority": "HIGH",
    "procedure": {
        "id": 1711611,
        "title": "Alert Triggered Water Pump Inspection",
        "fields": [
            {
                "type": "HEADING",
                "label": "Warning: Only authorized technicians should perform this inspection."
            },
            {
                "type": "INSPECTION_CHECK",
                "label": "Check for visible signs of damage to Water Pump"
            },
            {
                "type": "TEXT",
                "label": "If visible damage, state pumps condition on arrival"
            },
            {
                "type": "NUMBER",
                "label": "Record the current pressure reading of Water Pump Keyence Flow meter (from SCADA or From digital display on meter)."
            },
            {
                "type": "INSPECTION_CHECK",
                "label": "Inspect and verify the condition of the pump filters."
            },
            {
                "type": "TEXT",
                "label": "Inspect and verify the condition of the pump exterior."
            },
            {
                "type": "FILE",
                "label": "Upload a photo of the pump's condition"
            },
            {
                "type": "SIGNATURE",
                "label": "Technician's signature upon completion of the inspection."
            }
        ]
    }
}
token = "<your_bearer_token_here>"		# your bearerToken env variable here

headers = {
	"Content-Type": "application/json",
	"Accept": "application/json",
	"Authorization": "Bearer {}".format(token)		
}
 
# Sent a POST request (blocking)
response = client.post(url, data=body, headers=headers)
 
# Validate the response
if response.good:
    # Do something with the response
    print response.getJson()
[details="Summary"]
This text will be hidden
[/details]

It takes a little tweaking to get the authorization working sometimes, so I wouldn't be surprised if you got an error. I would actually be shocked if you didn't get an error.

1 Like