Solved

3rd Party API with IFS Connect

  • 24 January 2020
  • 15 replies
  • 2295 views

Userlevel 2
Badge +7

Hi,

I was hoping someone could help with setting up IFS Connect to send time registration to a 3rd party api.

I have created a test custom event where new or changed time registration information is submitted to IFS. My 3rd part company has an API for create time sheet eg https://api.company.com/createtimesheet . So I need to send the API key and respective time-sheet data from IFS. I am just ensure of the routing address/application message setup part. Would appreciate some screen shots of working example if possible

icon

Best answer by dsj 28 January 2020, 14:58

View original

15 replies

Userlevel 5
Badge +7

Have you considered creating a PL/SQL package to send the data to the RESTful timesheet web API and avoid using IFS Connect? This would be easier to troubleshoot and debug.

Userlevel 3
Badge +5

Cwright,

What version of IFS are you running?

 

 

Userlevel 2
Badge +7

We have recently upgraded to IFS v9. 

I do not have the greatest of expertise when it comes to building PL/SQL packages and want to avoid using external consultancy for help with that, so IFS connect seemed like the obvious choice.

Userlevel 7
Badge +20

Hi @cwright ,

 

Apps 9 built in HTTP sender is capable of sending HTTP POST with headers. Is this OK with your API? It would be nice to know what kind of input your API expects.

Userlevel 2
Badge +7

Hi @cwright ,

 

Apps 9 built in HTTP sender is capable of sending HTTP POST with headers. Is this OK with your API? It would be nice to know what kind of input your API expects.

 

 @dsj thanks yes i think so, but I was hoping for a working example with screenshots, is that anything you could share?

Userlevel 7
Badge +20

Hi @cwright ,

 

Here’s a simple example on how to route event response to IFS Connect

1. Event: Fires when any change to Description field

 

2. Event Action:

Type = Application message

3. Create New Outbound Routing Rule

Route From: APPLICATION_MESSAGE

Queue: NOTIFICATIONS

Routing Condition: MESSAGE_FUNCTION = [EVENT_ID]

Routing Address : In this example I use File Connector.

 

Output XML for this example looks like this

Note that it contains the Fields we selected in the Event

 

What you have to do

  • Create a Routing Address of type HTTP to send to your API
  • Create a transformer if necessary.

 

Cheers!

Userlevel 5
Badge +11

Hi all,

I am copying this process exactly in IFS 10 but when I try to carry out the action that triggers the event (i.e. changing the status of a Shop Order), I get the error shown below (“Element denoted by path [$EVENT_RECORD$] not found”). If I disable the Event Action, I can change the Shop Order successfully. Any ideas?

Many thanks,
Ged.

Userlevel 4
Badge +8

Hi Ged,

 

Please make sure you have included the required new/old fields in the event header.

 

Alternatively you can use plsql to generate the XML in the required format if you need values not available on that table.

Userlevel 2
Badge +7

Hi @cwright ,

 

Here’s a simple example on how to route event response to IFS Connect

1. Event: Fires when any change to Description field

 

2. Event Action:

Type = Application message

3. Create New Outbound Routing Rule

Route From: APPLICATION_MESSAGE

Queue: NOTIFICATIONS

Routing Condition: MESSAGE_FUNCTION = [EVENT_ID]

Routing Address : In this example I use File Connector.

 

Output XML for this example looks like this

Note that it contains the Fields we selected in the Event

 

What you have to do

  • Create a Routing Address of type HTTP to send to your API
  • Create a transformer if necessary.

 

Cheers!

@dsj 

I have been able to start implementing and testing this. I am having to use an XML to JSON transformer which seems to work when I output to a file and review the contents. However what I am struggling to do is include additional parameters as I need to send an APIKey and an action with the post . I have tried using the additional headers but that doesn’t seem to work.

 

Can you anyone help?

Userlevel 5
Badge +11

Do you mean something like this?

Custom attributes can be added which use variables from the main attributes list. We use them to add requisitioner details to the purchase order released event...

 

Userlevel 2
Badge +7

@GPIE 

I tried to use custom attributes but they only accept IFS PL/SQL APIs with parameter fields from the IFS Database. I need to insert a ‘hard-coded’ API key supplied by a 3rd party to send with the post to the 3rd Party’s API.

Userlevel 7
Badge +20

@GPIE

I tried to use custom attributes but they only accept IFS PL/SQL APIs with parameter fields from the IFS Database. I need to insert a ‘hard-coded’ API key supplied by a 3rd party to send with the post to the 3rd Party’s API.

Hi @cwright ,

 

I’m not sure why the additional headers  properties does not work. Can you show how you set it up?

However, if you need to add a static value in the XML, there are several ways.

 

One way is to add a public custom field in a common window and access it via generated get method.

Otherwise, I usually use Conversion List in data migration basic data to store common static values.

Example setup is given below

Add static value in the conversion list

Add the static value in a conversion list

 

Add a custom attribute to the event

Add a custom attribute 
 

Server method syntax

intface_conv_list_cols_api.get_new_value('DEFAULT_VALUES','APP_API_KEY')

Now the value should be include in the XML

 

Hope it helps!

Damith

Userlevel 2
Badge +7

@dsj  Thanks for that information, do you have any recommendations for handling column names, eg my API is expecting employeeId and the application message includes NEW_EMP_NO, also the application message includes fields I don’t want , anyway to exclude them?

Userlevel 4
Badge +8

Use a transformer to push the message out as required

Userlevel 7
Badge +20

Use a transformer to push the message out as required

I also agree with @Mike.Hollifield  , with a transformer you can change the field names, exclude unnecessary tags and put into any structure you need.

Reply