# Generating a Work Order to MaintainX from Ignition?

**URL:** <https://forum.inductiveautomation.com/t/generating-a-work-order-to-maintainx-from-ignition/87931>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [March 26, 2024, 10:55pm UTC](https://forum.inductiveautomation.com/t/generating-a-work-order-to-maintainx-from-ignition/87931 "2024-03-26T22:55:51Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryan\_Crawford](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@Ryan\_Crawford](https://forum.inductiveautomation.com/u/Ryan_Crawford)\
**Post date:** [March 26, 2024, 10:55pm UTC](https://forum.inductiveautomation.com/t/generating-a-work-order-to-maintainx-from-ignition/87931/1 "2024-03-26T22:55:51Z")

</div>

Good afternoon,

I am interested in trialing the CMMS platform MaintainX. Specifically, I would like to automatically generate a work order when a process variable exceeds a set limit.

Currently, I will be using an MQTT broker (the distributor) but I am unsure how to transfer information from Ignition to MaintainX. I understand that it likely needs to be done via an API, but I am unfamiliar with the process. Would an additional platform need to sit between the Ignition broker and MaintainX?

Any advice to point me in the right direction would be greatly appreciated.

Thanks,  
Ryan

Also apologies if this is not the corret place to ask this question.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 26, 2024, 11:00pm UTC](https://forum.inductiveautomation.com/t/generating-a-work-order-to-maintainx-from-ignition/87931/2 "2024-03-26T23:00:43Z")

</div>

> [@Ryan\_Crawford](#):
>
> Currently, I will be using an MQTT broker (the distributor) but I am unsure how to transfer information from Ignition to MaintainX.

Well, it sounds like you're speccing yourself into trying to use MQTT to transfer information, in which case you would have to either explicitly publish the information to topics in the broker or rely on tags being published via MQTT Engine.

This is probably the wrong approach though. Integration with systems like this is typically done via web service calls. You can make HTTP calls from Ignition scripting using the `system.net.httpClient` function, and you can receive inbound HTTP calls using the WebDev module.

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [March 27, 2024, 2:38pm UTC](https://forum.inductiveautomation.com/t/generating-a-work-order-to-maintainx-from-ignition/87931/3 "2024-03-27T14:38:43Z")

</div>

> [@Ryan\_Crawford](#):
>
> MaintainX

Going off of what Kevin said, I would use an HTTP client and not overcomplicate things with MQTT. This is even more so the case, since MaintainX seems to have a [pretty APIs and documentation](https://api.getmaintainx.com/v1/docs#tag/Work-Orders/paths/~1workorders/post) on their site:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/c/dc3b716a767efab977850678350adbd4d8acb3bc.png)

The screenshot above is for creating a work order, so as long as you have or can generate those fields in Ignition to pass into the body of the API call, you should be able to do this. One thing I would look into is whether the API layer is free or not - you'll need to make an API key, which may require an account, etc. There are also usually rate limits with APIs for modern web services, to avoiding overloading their system, so if you are generating 10 work orders per second (theoretically), some requests may be dropped. Again, I haven't read through their rate limit documentation, I just made those numbers up, but you get the idea....

---

<div class="post-metadata">

**Author:** ![Ryan\_Crawford](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@Ryan\_Crawford](https://forum.inductiveautomation.com/u/Ryan_Crawford)\
**Post date:** [March 30, 2024, 12:26am UTC](https://forum.inductiveautomation.com/t/generating-a-work-order-to-maintainx-from-ignition/87931/4 "2024-03-30T00:26:28Z")

</div>

Hey,

Thank you for your response. Based on your instructions, I've managed to create a work order using Postman, leveraging my MaintainX account.

Now, I'm curious about integrating this process with Ignition. How would I go about linking Ignition to MaintainX? Since I can establish a connection with Postman, I assume the content is good; I just need guidance on addressing MaintainX from Ignition.

I've reviewed the Webdev notes in Ignition, but I must admit, I'm quite inexperienced in this area. Any assistance would be greatly appreciated."

Thanks,

Ryan

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [April 1, 2024, 2:49pm UTC](https://forum.inductiveautomation.com/t/generating-a-work-order-to-maintainx-from-ignition/87931/5 "2024-04-01T14:49:55Z")

</div>

I don't believe you'll need the WebDev module - that is helpful when you want to **host** resources, not necessarily when you want to read/write resources to somewhere else.

You could just use the `system.net.httpClient` object and a few helper methods to accomplish what you want. If you post a screenshot of your Postman setup (blur out any authentication), then I can give you an approximation of what the equivalent in Ignition is.

---

<div class="post-metadata">

**Author:** ![Ryan\_Crawford](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@Ryan\_Crawford](https://forum.inductiveautomation.com/u/Ryan_Crawford)\
**Post date:** [April 1, 2024, 4:08pm UTC](https://forum.inductiveautomation.com/t/generating-a-work-order-to-maintainx-from-ignition/87931/6 "2024-04-01T16:08:11Z")

</div>

@YF129701 Thanks for the help, I really do appreciate it.

Here is the details I think you are after.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/8/2898eea833e0dcf9e37c9107cc7cce6f73c97f7c.png)

And here is the code example:

````auto
//Want to look up assest online or offline
{
    "title": "Inspection of Water Pump #1 PN:111 (Pump House), Vibration Warning",
    "assetId": 5054334,
    "assignees": [
        {
            "id": 82364,
            "type": "TEAM" // dont know what this means
        }
    ],
    "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."
            }
        ]
    }
}```
````

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [April 1, 2024, 4:27pm UTC](https://forum.inductiveautomation.com/t/generating-a-work-order-to-maintainx-from-ignition/87931/7 "2024-04-01T16:27:34Z")

</div>

Yep, those are great! Just a few more things so I can get as close as possible - can you send the Body and Headers panes in Postman?

Like so:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/8/78167cb7316befd8438498245039735959b84d4a.png)

and

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/6/16cd7bd8f0390d50ecd6c0831bb325a7f48c17fe.png)

---

<div class="post-metadata">

**Author:** ![Ryan\_Crawford](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@Ryan\_Crawford](https://forum.inductiveautomation.com/u/Ryan_Crawford)\
**Post date:** [April 1, 2024, 4:44pm UTC](https://forum.inductiveautomation.com/t/generating-a-work-order-to-maintainx-from-ignition/87931/8 "2024-04-01T16:44:28Z")

</div>

This,

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/0/80c1b3813fb27be693f3080ef2873d760d5b9ce2.png)  
and this,  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/9/79550c3b52960a943e0ea895a5e65bb2852043c5.png)

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [April 1, 2024, 4:59pm UTC](https://forum.inductiveautomation.com/t/generating-a-work-order-to-maintainx-from-ignition/87931/9 "2024-04-01T16:59:55Z")

</div>

On the headers snip, can you hit the `8 hidden` and show what's in there? What I'm looking for is the bearer token - it should be part of the header iirc.

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [April 1, 2024, 5:07pm UTC](https://forum.inductiveautomation.com/t/generating-a-work-order-to-maintainx-from-ignition/87931/10 "2024-04-01T17:07:51Z")

</div>

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**
>
> ```python
> # 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.

---

<div class="post-metadata">

**Author:** ![Ryan\_Crawford](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@Ryan\_Crawford](https://forum.inductiveautomation.com/u/Ryan_Crawford)\
**Post date:** [April 1, 2024, 6:24pm UTC](https://forum.inductiveautomation.com/t/generating-a-work-order-to-maintainx-from-ignition/87931/11 "2024-04-01T18:24:05Z")

</div>

Sorry, here is the complete header

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/5/558914ad2fc84d828d71b91318bc448a42db7848.png)

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [April 1, 2024, 7:04pm UTC](https://forum.inductiveautomation.com/t/generating-a-work-order-to-maintainx-from-ignition/87931/12 "2024-04-01T19:04:18Z")

</div>

[Try the code](https://forum.inductiveautomation.com/t/generating-a-work-order-to-maintainx-from-ignition/87931/10) in the post just above this one - I think the Authorization needs to be tweaked, but if you run it, you'll probably get an error message that points you in the right direction.

---

<div class="post-metadata">

**Author:** ![Ryan\_Crawford](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@Ryan\_Crawford](https://forum.inductiveautomation.com/u/Ryan_Crawford)\
**Post date:** [April 1, 2024, 10:33pm UTC](https://forum.inductiveautomation.com/t/generating-a-work-order-to-maintainx-from-ignition/87931/13 "2024-04-01T22:33:27Z")

</div>

I owe you a beer my friend! It worked first time!

It was complaining about the:

[details="Summary"]  
This text will be hidden  
[/details],

But after removing no troubles.

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [April 1, 2024, 10:35pm UTC](https://forum.inductiveautomation.com/t/generating-a-work-order-to-maintainx-from-ignition/87931/14 "2024-04-01T22:35:09Z")

</div>

Damn now I'm scared... My code never works first time 👻

---

<div class="post-metadata">

**Author:** ![Ryan\_Crawford](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@Ryan\_Crawford](https://forum.inductiveautomation.com/u/Ryan_Crawford)\
**Post date:** [April 1, 2024, 11:01pm UTC](https://forum.inductiveautomation.com/t/generating-a-work-order-to-maintainx-from-ignition/87931/15 "2024-04-01T23:01:40Z")

</div>

Hahah now you know you must be an expert! Thanks mate, really appreciate it.
