Search

How to Call an ION API from Mongoose

Overview

Enabling smooth communication between Infor Mongoose, a low-code development platform, and ION API is crucial for businesses seeking to maximize the full potential of their cloud ecosystems. Being able to call an ION API from Mongoose unlocks the possibility of integrating custom applications created in Mongoose with other parts of the Infor cloud ecosystem or even third-party applications.


Components

Requirements

  • Access to Infor Mongoose
    • MONGOOSE-UG-CoreFormsAdmin
    • MONGOOSE-UG-CoreFormsDeveloper
    • MONGOOSE-UG-CoreFormsEndUser
    • MONGOOSE-UG-CoreIDOs
  • ION API Gateway (IONAPI-Administrator)

Tutorial

Difficulty: Medium
Estimated completion time: 45 Minutes

This tutorial will show you how to call an API from a Mongoose application and how to leverage Mongoose as a client to call an API. This will allow any application developed within Mongoose to be connected to the suite of Infor products.

Authenticating Mongoose through ION API Gateway

This section covers the technical details of ION API and its oauth2 design. It will show examples of how to call ION API from various clients.

The image below shows various usage scenarios with multiple clients. Mongoose uses the resource owner of Grant, which authenticates seamlessly without user intervention. It does this by using a service user to impersonate a user or by enabling SSL.

We need to generate the ION API file with our secrets and keys.

Click on the API Gateway tab. On the navigation menu click Authorize Apps, we click the (+) Add button.

On the Non-Infor New Authorized App page, fill in the Name field with MongooseIONConnect, and in the Type, field select Backend Service. Give it a Description of mongoose, and click Save.

Scroll to the bottom of the page and click the Download Credentials button.

NOTE: In the case that SSO is not enabled, we need to provide a Service Account for Mongoose to impersonate for the ION API calls to succeed.
Also, ensure the Service user you impersonate has permission to access the API you want; otherwise, you will receive an unauthorized response.

Click the Download button.

You should see an .ionapi file downloaded.

Import the .ionapi file into Mongoose.

Click the Mongoose tab and click OK on the Mongoose environment.

On the Mongoose Runtime Mode page, click Form and Open.

Filter on ION API Services and select IONAPIServices form, click Ok.

Click the Import .ionapi file button.

Drag and drop the .ionapi file you just downloaded into the Import Binary Data From File section. Click Upload.

In some cases you may see that it already exists. but if it doesn’t import the file.

NOTE: An important thing to keep in mind is that after every redownload of the credentials, you will have to re-import the .ionapi file into Mongoose to keep the information up-to-date.

Testing ION API connection in Mongoose

On the Mongoose Runtime Mode screen, click Form and Open.

Filter on ION API Invoke and select the IONAPITestInvoke form. Click Ok.

Get a simple API to test the ION API connection. In this example, we selected the Infor Mingle API. Select the API Gateway tab and from the navigation menu select Available APIs. Select the Infor Mingle API.

Click on the Documenation icon and get the user’s Social Details.

Scroll down to the SocialData section and on /SocialService.Svc/User/Detail click the GET button. Then click the Try out button.

Click the Execute button.

You can see a successful response

Let’s replicate this call within Mongoose. Go to the Mongoose Runtime Mode page and on the Test ION API Invoke form (which should already be open), fill in the following fields.

  • Service ID: 0
  • Suite: Mingle
  • HTTP Method: GET
  • Method: /SocialService.Svc/User/Detail
  • Timeout:10,000
  • Parameters: [{“Name”:”Accept”,”Type”:”header”,”Value”:”application/xml”}]

Parameters Field NOTE: Mongoose takes in Parameters as an array of JSON. Each JSON entry should have three keys. Name, Type, and Value. For this call, we want to add an Accept header. So the Name would be Accept, the Type would be header and the Value would be the type of the response we’re getting, which is application XML.

Leave the Content Type blank because that’s used to tell us the type of payload for post requests. Click Invoke.

You will notice that our response code is 200 and the content we received proves that our connection is successful. This shows a successful ION API query to Mingle.

Get Images from IDM through ION API calls in Mongoose

Here is an example form (IDMCarouselYJ). This form tells ION API what to query and returns a list of images that we set the carousel with.

Let’s take a look at how ION API is called within this form.

We opened Mongoose in Design mode by clicking the following designer icon.

On the Identify Your Editing Scope, we selected Site Default. then clicked Ok.

In this example, we opened the (IDMCarouselYJ) form.

We will take a look at the forms events.

NOTE: We can open the Form Details by clicking on the Icon in the lower righthand corner of the form screen.

You see three Event Handlers in StdFormPredisplay that are triggered on form load.

Let’s take a look at what the Form Script method setIDMVars does.

We clicked on the Form Script Method Response Type and selected the pencil Icon in the Properties section. We then selected Edit Form Script.

If you remember the Test ION API Invoke form we used earlier, we had to set these values for ION API to know what to query. The list of variables you see below are all the input variables that ION API consumes. As long as these are set correctly ION API should work. We will click Ok.

After setting the input variable the next event is a call to the Mongoose ION API method.

From the Event Handlers section within the Form Details window, we selected the Method Call, expanded Response, and in the Parameters field click on the Ellipsis.

From the Event Handlers Parameters screen, we clicked on the Parameters Ellipsis.

You can see we are passing in the input variables and expecting four output variables. The variable RVAR V(varCarouselResponse) is responsible for this multi-line edit. We click Ok until you return to the main form screen.

These two steps are what was needed to use ION API on this form. First, set the input variables for your call and then invoke the method passing in those input variables.

We’ve now shown you how to do different get requests to Mingle and IDM, the mythology is the same for any other get requests.

ION API POST call from Mongoose

Let’s take a look at how to do a Post on this form. We have three ways of triggering an ION API Post to IDM. One to the Form, one to AES, and one to the Custom Assembly. In this example, we will use a prebuilt form (IDMPostYJ).

We opened the IDMPostYJ form in Design mode. We selected the Post button and expanded the Form Details.

There is a POST event attached to the button that first sets the input variables and then invokes the ION API method just like the GET requests.

The main difference between the POST and GET is the input variables. HTTP method, parameters, and Content Type.

In the parameters variables, for our GET example, we only had one JSON entry specifying the accept header, our POST request requires a second JSON entry telling the API what to post via the body payload. The body format is taken from the IDM Swagger doc and I recommend testing the post there first. We set the Content Type to be application/json because that’s what we are passing in the body value.

Let’s see how it works. We went back to the Mongoose Runtime mode and on the IDMPostYJ form, we clicked the Post button.

You can see in the responses that we are getting a 200 HTTP and the content that has been posted.

If I go into Document Management now and refresh Recently Modified you can see the post.

Let’s see what the Post through AES button does, it has an Event listener that generates an application event. We clicked on the Parameters ellipsis to view the Event Handler Parameters.

This is a custom application event that was created.

We will go to the Events form, in Mongoose Runtime mode, select Form, and then select Open.

Filter for and select Events. Click Ok.

From the Event Name fields drop-down, we selected the PostIDMDecument event and clicked on the Filter In Place Icon.

We then clicked the Event Handler button.


You can see there is one Event Action associated with it, which does a Call IDO method. We will Click the Event Action button.

We clicked the Show Details button.

Then we clicked the Edit Parameters button.


The action is calling the ION API method and passing it the same Parameters like I did in the form.

We Clicked the Parameters button to view all the values.

In Mongoose Runtime Mode, If we go back to the IDMPostYJ form.

We will click the Post through AES button.

If we go back into Document Management and refresh we can now see that you have two pulses to IDM.

Besides calling the ION API directly on the form or doing a Post through AES the third way is to call a Post through a Custom Assembly. You can see there’s a Method Call to a meta attached to an IDO called PostToIDM. We would click on the Parameter ellipsis, to bring up the Event handler Parameters to view the PostToIDM method call.

Going into that method call, we would go to the Mongoose runtime mode, click Form, and select the IDOs form.

Fill in the IDO Name and click the Filter In Place Icon.

You can see that the Post to IDM method is coming from the IDMPost Assembly.

When we open up the IDO Custom Assemblies form. We clicked Form -> IDO Extension Class Assembles.

We clicked the Filter In Place Icon, select the IDMPost assembly, and clicked the Source Code button.

Viewing the source code, you can see the PostToIDM method. Here it is setting the ION API input variables just like we did on the Form and in AES.

And invoking the API method.

We now return to the Mongoose runtime mode and click the Post through a Custom Assembly button.

We return to Document Management to see the third ION post in Document Management.

You now have three ION posts to IDM. Using three different methods in Mongoose.

For the steps mentioned above, refer to the video below.

Resources

Help Documents and User Guides