Integration made easy: Infor M3 & Python

Guastalli Davide
4 min readJul 5, 2021
Photo by Sigmund on Unsplash

Hi All! Today our mission is to integrate an external application, written in Python, and our ERP. As an example, we can use a B2B Order system to get orders from a web platform.

In the meanwhile I’d like to introduce myself: I’m Davide Guastalli, Senior Technical Consultant on Infor M3 and on the whole Infor OS stack.

As you might know, Infor M3 use API in a massive way. They’re natively exposed outside M3 also as REST web services (along with the standard MvxAP socket port.)

We’re working on the on-premise version (at the moment 15.1.4), because on the Multi-tenant cloud (aka Infor M3 CE) works with another method that we’ll analyze in another post: using ION API as a gateway to expose M3 Api and manage authentication.

How M3 API is structured

First step is to understand which is the correct TCP port where rest API are available.
We need to use the LifeCycle Manager, core of the whole infrastructure, to find it out.

Let’s find our correct Business Engine and then follow“Monitor Application”:

We enter in the monitoring console

Expand the “M3Router” line and look for System.HTTP and System.HTTPS ports.

Http and Https ports.

Now we can move to the Python application.

What I did as a first step is to include some tools on my project:
- requests (to simplify our REST communication)
- json (to read web services responses)

In my case I also have
- csv ,because I launch some APIs based on an input .csv to automate a process
- urllib3, because of a self-signed certificate in TST environment, I need to use urllib3 to disable warnings (of course is discouraged in PRD!)

Import details

The endpoint we’ll use is “m3api-rest/v2/execute”, authentication type will be “Basic” (please make sure is enabled on the Router).
So let’s write the first snippet of code: parameters and two helper to build the webservice call.

In parameters we’ll add also the CONO — Company on which we need to call all the API calls.
Of course you can better implement the authentication part to not have the parameters hard-written in the source code.

minm e trnm represents our M3 API (MMS200MI) and our transaction (In our example: GetItmBasic)

Another helper that I’ve build, as I’m using only Get calls, it’s called getM3GetField.

The standard response is usually this:

JSON Example response

My helper will get the first record (as I’m using a “Get” it’s always the only record I’ve) and retrieve the field value.

getM3GetField Example

Now we can call our API and check if it’s working

API call

Just a point of attention: if APIs goes in error (for example the Item does not exists) the status_code will be always 200.

My suggestion is to check if exists “errorMessage” or “errorCode” field in this case and manage it in our application. Down here you can find an unsuccessful request response.

errorMessage and errorCode

Stay tuned for other integrations and guides!

--

--

Guastalli Davide

Senior Technical Consultant on Infor M3 and Infor OS Technical stack. +10yrs on consultancy, technology addicted, currently employed at Horsa Group