Help matching API response array items to existing records

Hi,
I’ve read the ‘help’ documents and tinkered for a while but I can’t get this to work correctly.

Context:
One of our MATS applications is used to evaluate customer applications, successful applications are then POST to a 3rd party REST API for the final stage of processing.

Some customer data already exists in the 3rd party API prior to the MATS system going online, and some customer data is POST to the API outwith MATS.

The customer data in the API can be changed outwith MATS.

My point here is; there is not a one-to-one relationship between a record in MATS and the 3rd party API. Every successful applicant’s record in MATS has a record in the API, but not every record in the API will have an application record in MATS.

My goal:
Call the API each night in order to track changes to the customer records.

What’s not working:
I have an API Request object and an object for the Local Summary of API records.
An API call is configured with a base object of the Local Summary and the relation path is to the API Request object.
The “Request selection” is set to “none”, as the API call is independent to any specific record.
The “Action” is “Match else create”, as each night this should update the previous night’s record data, or create new Local Summary where there is a record in the API that doesn’t exist yet in MATS.

The response data is of the format below, where the data array can be any length from 0 to 200 items

{ “data”:[
{
“item_id”:“ABC1”,
“item_state”:“ACTIVE”,
“item_renewal_date”:“2019-09-24”
},
{
“item_id”:“ABC2”,
“item_state”:“CANCELLED”,
“item_renewal_date”:“2019-10-20”
},
{
“item_id”:“ABC3”,
“item_state”:“NEW”,
“item_renewal_date”:“2020-09-18”
}]}

The help documentation states that MATS will know to iterate on the data items.
I’ve tried creating the response body as per the help doc, but also tried using adding an API reponse template into the JSON response.

Neither do what I want.

How should I construct the response body to iterate on all data items received and “match else create” using the item_id?

For info what goes wrong is one of the following:

  • Only the first data item is action-ed, and isn’t matched, a duplicate is created
  • Using the template all data items are action-ed and created as new records. matching doesn’t work
  • a new record is created for each property within data item 1.

Thanks
Craig

Afternoon Craig,

Can you confirm that your response looks like this and is to an object above the target object for the iterations, this might mean you use the API Object as your primary with a one to many relation to the child template.

{"data":[
TEMPLATE
]}

Your template through a parent to the child should then look like:

{“item_id”:“ABC1”,
“item_state”:“ACTIVE”,
“item_renewal_date”:“2019-09-24”}

This being just one instance of your sample containing all available elements:

If you have any questions about setting up an alternative base object let me know.

Hi Adam,
My response does look like:

{“data”:[
TEMPLATE
]}

But my template differs, it looks like…(with the curly-brackets)

{ “item_id”:“ABC1”,
“item_state”:“ACTIVE”,
“item_renewal_date”:“2019-09-24”}

My base is the Local Summary object and I have a one-to-many relationship to itself to add the template.

I’ve tried using the API object as the base for the API call, but I then lose the options to match/match else create.

Hi Craig,

I did exactly this yesterday - and my template has curly braces too. If you have a 10.3 system I can package it up as a module for you to compare with the data objects and pages (It’s a public API) If not I can do a series of screen shots…

RIchard

Hi Richard,
Thanks. I tried removing the curly braces but got a syntax error. I guess it was a typo above.

I think the trick must be getting the relationship right between the base object, child object and the API object.

I’m on 10.2, thanks for the offer. Could you please screenshot the basic tab of the API call, the response tab and the template basic (showing how the properties in the template are related to the template base object).

Kind regards
Craig

Apologies Craig that was my omission, do you have some time this morning for us to have a screen share using support.netcall.com? Could you let me know if the template is set up via a relationship or as an independent object.

I should be available for a screen share. The template is setup via a relationship.

If you ping me your email address to richard.kelly@netcall.com I will send you the screenshots - I can’t upload here…

Hi Adam, can we schedule in the screenshare?
I’ve replicated Richard’s structure, but I’m still not able to match the templated item properties. I can’t see what I’ve missed, but another pair of eyes usually help.

Regards
Craig

Hi @CraigBarker_Cumbria

Bit late but just saw this and we recently had the same issue. If it helps we never could match, but we were matching on records in a related object to that of the call (although that relation was already created before the call).

However we got around it by always saving the response values as new records, and then triggering rules to match those new “response records” with the records we actually wanted to match on so we could do what we needed to on those. See screenshots below for our setup:

Basics tab:

Response:

Rules:

Best wishes
James

2 Likes

@james.coleman ,
This is great thank you. My instinct tells me that I should be able to match, but until I work it out I’ll implement your working solution.

Many thanks
Craig

Morning Craig, If you message me when you have a window this morning, let’s screen share and see if we can’t figure out where the issue is.

For the benefit of anyone following this thread, there were potentially two issues that weren’t immediately obvious with the configuration.

  1. The reference ID had been set to encryption Level 2 and this was preventing a successful match forcing a create.

  2. The references were not guaranteed unique, firstly because the ID was not set as unique, but also potentially due to previously failed calls. Be sure to clean up after failed calls where data created in error may interfere with future successes.


    It is also worth noting that if you wish to use the API Object as the base object for your call, you will only have auto-match available for parsing your response. In the case of auto-match you need to use link for iteations/templates as opposed to match.
3 Likes

As above, I can confirm this is now working. Thanks for your help @adam.mills

2 Likes