Post HTTP request using Automation script

I want to post a simple JSON message to an external system and do not want to add any external library to Maximo as it would require a restart. 

In the past, I used the java HTTPClient library that comes with Maximo, but it would require half a page of boilerplate Jython code. Recently, I found a simpler solution below.

  • First I use WebHook as a mock service for testing. Go to webhook.site, it will give us a unique URL to send request to:



  • Go to the "End Point" application in Maximo to create a HTTP Endpoint
    • End Point Name: ZZWEBHOOK
    • Handler: HTTP
    • Headers: Content-Type: application/json
    • URL: <copy/paste the Unique URL from webhook>
    • HttpMethod: POST

  • To ensure it's working, Use the Test button, write some simple text, then click on "TEST". Maximo should show a successful result. In Webhook, it should also show a new request received. (Note: if it gives an error related to SSL, it's because Websphere doesn't trust the target website. You'll need to add the certificate of the target website to Websphere trust store)


  • To send a request, just need two lines of code as follows:


Happy coding!















7 comments:

  1. I dont know why, if I post the request to webhook.site its work fine, but when I try to sent the request to my own API server (external resource) from maximo it doesnt work, so this mean maximo endpoint only works for webhook similar server that not sent the response back to maximo or is there something that I missed here? I'm so appreciate if you could give me some guidance to work with maximo end point.

    ReplyDelete
    Replies
    1. Is your API running on SSL? If yes, you have to add the certificate to Websphere trust store

      Delete
  2. Yes correct the API server running on ssl and our maximo on weblogic.

    ReplyDelete
  3. Hi Viet,
    Do you know a way in automation script re-write the URL on an HTTP end point in Maximo? For example, I am integrating Maximo to an external system using a REST API. I can successfully send a POST request to an end point to create a record in an external system. But when my original record in Maximo is updated later, I want to send a PUT request to update the record and need to pass the record ID as part of the API call. The HTTP end points URL has an "override" checkbox, but don't seem to have a straightforward way to include a substitution variable to pass a value to include in the URL.

    ReplyDelete
    Replies
    1. What are you trying to do? Sending a PUT request from External System to Maximo or from Maximo to External System? For the lowest level implementation (when everything else fails): for Ext System -> Maximo: look at "Creating REST apis using Automation Script" section in the Automation Script feature guide for 7.6.0.9. It essentially allow you to build any REST api using script. For Maximo -> External System, you can utilize a core java Http Client package in automation script

      Delete
  4. thank you for posting this guide , but how can i add basic authentication to my API call ?

    ReplyDelete
    Replies
    1. For authentication, you have to set it up in the Endpoint

      Delete