Search code examples
maximo

Maximo- Update work order using RESTApi by passing wonum and siteid instead of workorderid


We are currently on Maximo 7.6.1 and have started to use Restful APIs and was wondering if there is a way to update a work order using RESTApi by passing wonum and siteid instead of workorderid.

We would like to avoid one additional GET call for our middleware to retrieve the workorderid and then use it in the PUT request.

Using this URL (OS as well) tries to insert a record even though the HTTP method is PUT.

/maxrest/rest/mbo/WORKORDER?_action=AddChange&siteid=XXX&wonum=7065644&description=Testing

Any pointers will be helpful.

Thanks


Solution

  • The IBM documentation appears to suggest you can only update existing records with the unique ID:

    Use the PUT method to update or insert a resource. An update request must provide the unique ID of the resource. To update an object structure resource, the ID of the main object is required.

    https://www.ibm.com/support/knowledgecenter/en/SSLKT6_7.6.0/com.ibm.mif.doc/gp_intfrmwk/rest_api/r_rest_put_method.html

    The response received using the url you provided appears to bear this out in as far as it indicates the work order cannot be created as it already exists:

    Error 400: BMXAA4129E - The record for Site=BEDFORD, Work Order=1234 already exists. Ensure that the key value for the given record is unique.

    Reviewing the information at the following url I wasn't able to determine a method to perform the update without the unique ID:

    https://www.ibm.com/developerworks/community/wikis/form/anonymous/api/wiki/02db2a84-fc66-4667-b760-54e495526ec1/page/87348f89-b8b4-4c4a-94bd-ecbe1e4e8857/attachment/0a884bde-d17e-471b-b046-7f8feddfd267/media/MaximoNextGenRESTAPI%20%281%29.pdf

    In addition the Maximo RESTful API Swagger documentation indicates a POST to /os/mxwo is used to "Create a new resource":

    /maximo/oas3/api.html?includeactions=1#/Work_Order_Definition_(MXWO)/post_os_mxwo

    Whilst a POST to /os/mxwo/{id} is used to "Update WORKORDER Object":

    /maximo/oas3/api.html?includeactions=1#/Work_Order_Definition_(MXWO)/post_os_mxwo__id_

    I was however able to update an existing work order using the unique ID. This being the case I can only suggest one of the following:

    1. If you're creating the work order first using the REST/OSLC API, retrieve and store the unique ID from the response received when the record is created.
    2. If (1) above is not possible, perform a GET and use parameters in the query to filter on wonum and siteid and only receive back the minimum of fields (e.g. workorderid only).
    3. If neither (1) or (2) are feasible investigate whether it's possible to customise Maximo and create your own endpoint for the work order object structure that takes wonum and siteid as parameters, retrieves the mbo and performs the update.