Topic
  • 14 replies
  • Latest Post - ‏2018-09-26T13:51:58Z by Bob_Richardson
jonsnow_10
jonsnow_10
21 Posts

Pinned topic Query WOrkorder table through REST API call

‏2018-09-17T14:52:27Z | maximo76

I am trying to query workorder table through Rest api but i am not able to do whrough wonum value.

I did with workorderid but not able to do with wonum.

http:/host-dev.abc.com/maxrest/rest/mbo/workorder/1088, can someone suggest me how to query based on wonum not workorderid.

  • Bob_Richardson
    Bob_Richardson
    7 Posts

    Re: Query WOrkorder table through REST API call

    ‏2018-09-17T16:31:05Z  

    You have a few options and here are a couple of examples:

    Your example is close but will default to the record id without specifying parameters.  

  • AJ@Maximo
    AJ@Maximo
    18 Posts

    Re: Query WOrkorder table through REST API call

    ‏2018-09-18T04:58:29Z  

    Using MBO:  

    http://host-dev.abc.com/maxrest/rest/mbo/workorder/?wonum=~eq~1088&_lid=userid&_lpwd=password&_format=xml

     

    Using object structure:

    http://host-dev.abc.com/maxrest/rest/os/MXWO/?wonum=~eq~1088&_lid=userid&_lpwd=password&_format=xml

     

  • jonsnow_10
    jonsnow_10
    21 Posts

    Re: Query WOrkorder table through REST API call

    ‏2018-09-18T10:01:21Z  

    You have a few options and here are a couple of examples:

    Your example is close but will default to the record id without specifying parameters.  

    I tried with your OS but I am getting below error,

     

    BMXAA0024E - The action READ is not allowed on object WORKORDER. Verify the business rules for the object and define the appropriate action for the object.

    But I have given access to maxadmin for this OS abd I am part of maxadmin. That OS has also read access only in OS security.

     

  • jonsnow_10
    jonsnow_10
    21 Posts

    Re: Query WOrkorder table through REST API call

    ‏2018-09-18T11:08:35Z  

    You have a few options and here are a couple of examples:

    Your example is close but will default to the record id without specifying parameters.  

    I am able to call to Rest api http:/host.com/maxrest/rest/mbo/workorder?wonum=PPSF2698263&_format=json but it is promting for userid and pwd. I tried your format also

    http://host.com/maxrest/rest/os/mxwo?_lid=maximo_username&_lpwd=maximo_password&wonum=PPSF2698263&_format=json still it promts for PWD. then what is the point of passing userid and pwd in request. Better way to do session handling here for nice user experience.

  • Bob_Richardson
    Bob_Richardson
    7 Posts

    Re: Query WOrkorder table through REST API call

    ‏2018-09-18T14:11:09Z  

    I am able to call to Rest api http:/host.com/maxrest/rest/mbo/workorder?wonum=PPSF2698263&_format=json but it is promting for userid and pwd. I tried your format also

    http://host.com/maxrest/rest/os/mxwo?_lid=maximo_username&_lpwd=maximo_password&wonum=PPSF2698263&_format=json still it promts for PWD. then what is the point of passing userid and pwd in request. Better way to do session handling here for nice user experience.

    I took your url, http://host.com/maxrest/rest/os/mxwo?_lid=maximo_username&_lpwd=maximo_password&wonum=PPSF2698263&_format=json, changed the wonum and user name and password and it worked for me in my 7.6.0.8 environment.  The _lid and _lpwd parameters will only work in a Maximo system using native authentication.  So a couple of questions:

    • Are you using LDAP or native Maximo authentication?
    • What Maximo version are you using?
  • jonsnow_10
    jonsnow_10
    21 Posts

    Re: Query WOrkorder table through REST API call

    ‏2018-09-18T19:24:43Z  

    I took your url, http://host.com/maxrest/rest/os/mxwo?_lid=maximo_username&_lpwd=maximo_password&wonum=PPSF2698263&_format=json, changed the wonum and user name and password and it worked for me in my 7.6.0.8 environment.  The _lid and _lpwd parameters will only work in a Maximo system using native authentication.  So a couple of questions:

    • Are you using LDAP or native Maximo authentication?
    • What Maximo version are you using?

    I am using LDAP authentication and maximo7.6.

  • Bob_Richardson
    Bob_Richardson
    7 Posts

    Re: Query WOrkorder table through REST API call

    ‏2018-09-18T20:47:21Z  

    I am using LDAP authentication and maximo7.6.

    Then it gets slightly more complicated.  You will need to pass some information in your HTTP headers.  I use Postman.

    • Encode your username and password in Base 64 like this [username]:[password] (Ex: maximo:maximo).  You can use the site recommended by Bruno Portaluri in this article.
    • Add the following properties to your header:
      • maxauth:[obtained in first step]
      • Content-Type: application/json
      • properties: *
    • Url will be something similar to this: http://host/maximo/oslc/os/mxwo?lean=1&oslc.where=wonum=1088

      • You'll be using OSLC since you need to pass some header information due to being LDAP enabled.

    You will get back a URL with a link to a specific record similar to this: http://host/maximo/oslc/os/mxwo/_QkVERk9SRC8xMTE2
    That URL will be to your specific record.
    More information can be found in this document. including how to additional search parameters, etc.

  • AJ@Maximo
    AJ@Maximo
    18 Posts

    Re: Query WOrkorder table through REST API call

    ‏2018-09-20T12:53:48Z  

    Then it gets slightly more complicated.  You will need to pass some information in your HTTP headers.  I use Postman.

    • Encode your username and password in Base 64 like this [username]:[password] (Ex: maximo:maximo).  You can use the site recommended by Bruno Portaluri in this article.
    • Add the following properties to your header:
      • maxauth:[obtained in first step]
      • Content-Type: application/json
      • properties: *
    • Url will be something similar to this: http://host/maximo/oslc/os/mxwo?lean=1&oslc.where=wonum=1088

      • You'll be using OSLC since you need to pass some header information due to being LDAP enabled.

    You will get back a URL with a link to a specific record similar to this: http://host/maximo/oslc/os/mxwo/_QkVERk9SRC8xMTE2
    That URL will be to your specific record.
    More information can be found in this document. including how to additional search parameters, etc.

    Hi Bob,

     

    We are using MAXREST instead of OSLC.

    LDAP is enabled in our system so what are the parameters we have to pass through header in this case ?

    I have tried above parameters with maxrest but no luck.

     

    Thanks,

     Ajay

  • Bob_Richardson
    Bob_Richardson
    7 Posts

    Re: Query WOrkorder table through REST API call

    ‏2018-09-20T13:22:42Z  
    • AJ@Maximo
    • ‏2018-09-20T12:53:48Z

    Hi Bob,

     

    We are using MAXREST instead of OSLC.

    LDAP is enabled in our system so what are the parameters we have to pass through header in this case ?

    I have tried above parameters with maxrest but no luck.

     

    Thanks,

     Ajay

    Hi Ajay,

    You would keep the HTTP headers the same as the Postman example earlier but your URL would look like one of the following depending upon your preference:

    If this doesn't work let us know the error you are receiving and how you are passing your HTTP header information.  

  • Bob_Richardson
    Bob_Richardson
    7 Posts

    Re: Query WOrkorder table through REST API call

    ‏2018-09-20T15:16:06Z  

    Hi Ajay,

    You would keep the HTTP headers the same as the Postman example earlier but your URL would look like one of the following depending upon your preference:

    If this doesn't work let us know the error you are receiving and how you are passing your HTTP header information.  

    Ajay,

    If the last post didn't work try this instead.  Replace MAXAUTH with Authorization and for the value use Basic [base64 encoded username:password]

  • AJ@Maximo
    AJ@Maximo
    18 Posts

    Re: Query WOrkorder table through REST API call

    ‏2018-09-21T05:02:31Z  

    Ajay,

    If the last post didn't work try this instead.  Replace MAXAUTH with Authorization and for the value use Basic [base64 encoded username:password]

    Hi Bob,

     

    This is working.

    Key: Authorization Value: Basic base64 encoded username:password

    I appreciate your time and effort to help me out

     

    Thanks,

     Ajay
  • Bob_Richardson
    Bob_Richardson
    7 Posts

    Re: Query WOrkorder table through REST API call

    ‏2018-09-21T13:41:41Z  
    • AJ@Maximo
    • ‏2018-09-21T05:02:31Z
    Hi Bob,

     

    This is working.

    Key: Authorization Value: Basic base64 encoded username:password

    I appreciate your time and effort to help me out

     

    Thanks,

     Ajay

    Awesome, Ajay.  Good to hear you got it working.

     

    Anyone else that stumbles upon this post you use MAXAUTH for Maximo Native Authentication and Authorization for LDAP authentication.  I kept referencing MAXAUTH in my earlier posts instead of Authorization without realizing it.  Hopefully this is now clear.  

  • jonsnow_10
    jonsnow_10
    21 Posts

    Re: Query WOrkorder table through REST API call

    ‏2018-09-25T12:36:11Z  

    Hi Bob,

     

    I want to learn more about maximo auth request. If i am making request from Postman then it is working good. But I want something like i want to store the token or cookie from the server response and use it for subsequent request instead of using username and password for each request. How can I do that. Thank you for your help. 

    Regards,

    Jon

  • Bob_Richardson
    Bob_Richardson
    7 Posts

    Re: Query WOrkorder table through REST API call

    ‏2018-09-26T13:51:58Z  

    Hi Bob,

     

    I want to learn more about maximo auth request. If i am making request from Postman then it is working good. But I want something like i want to store the token or cookie from the server response and use it for subsequent request instead of using username and password for each request. How can I do that. Thank you for your help. 

    Regards,

    Jon

    Hi Jon,

    Predictably, the answer is a little complicated.

    You would use something like the following to log into the integration framework and establish your session:

    GET /maximo/oslc/login?lean=1

    maxauth: <base64 encoded username:password>

    What you get back is a cookie that contains the JSESSIONID.  You can then pass this JSESSIONID on subsequent requests like:

    GET /maximo/oslc/os/mxasset?lean=1&oslc.pageSize=1&oslc.select=*

    maxauth: <base64 encoded username:password>

    JSESSIONID: <JSESSIONID from login cookie>

    Here is the complicated part, if you don't pass in the JSESSIONID Maximo will create a new session for each request which is less than ideal.  However, you will still want to pass in the maxauth header in case the JSESSIONID expires and you get a new session.

    So, in short, once you have your JSESSIONID you could pass that in place of maxauth but your session will expire at some point and your requests will fail.  Below is a screen shot showing what I am attempting to explain.