Original Message:
Sent: 06-22-2023 15:33
From: Muhammad Zubair Awan
Subject: Data Action Translation Map
When your data action output is an array, it gets mapped to collection of that data type. You will need indexing to extract individual elements. For example your first element will be Flow.customerMaster_zipcode[0]
You will need a Loop action in Architect to do what you need to do. For example to read all the elements, try this
Hope this helps
------------------------------
Cheers
Zubair
Original Message:
Sent: 06-22-2023 11:13
From: Jerry Sileon
Subject: Data Action Translation Map
that helped Zubair , as you could read I was trying to get all the data into one data action.......that is difficult in terms of trying to solve it with translation mapping. What i did is cut it in half and call two data actions instead. So the data action is published and shows values as a string collections
for some reason I can't read these collections and also not convert them a single string.
first i Try to do this:
and I try let an audio action speak the zipcode just to test if its correct
what goes wrong here.
------------------------------
Jerry Sileon
KPN B.V.
Original Message:
Sent: 06-21-2023 17:44
From: Muhammad Zubair Awan
Subject: Data Action Translation Map
now the problem is that I do have an data action that gives me the values that I want and I am able to set them in participant data in architect. But it's not flattened.....and therefore I can't do anything with it (I believe) because it's a string collection
If you are getting JSON data, you can store it in JSON variable in Architect. Then use GetJsonObjectProperty() function to extract the values
------------------------------
Cheers
Zubair
Original Message:
Sent: 06-21-2023 16:07
From: Jerry Sileon
Subject: Data Action Translation Map
Hi Zubair ,
for some reason I dont see where I can DM you , silly me!!
here is the data action export:
{
"name": "AA_Test_ORI - Customer Master Search v1 (Copy) (Copy) - Exported 2023-06-21 @ 21:57",
"integrationType": "custom-rest-actions",
"actionType": "custom",
"config": {
"request": {
"requestUrlTemplate": "https://api.accer/v1/search",
"requestType": "POST",
"headers": {
"Authorization": "${authResponse.token_type} ${authResponse.access_token}",
"X-SECRET": "057cae9af31f1c8d"
},
"requestTemplate": "${input.rawRequest}"
},
"response": {
"translationMap": {
"values": "$..results..keyring"
},
"translationMapDefaults": {
"values": "[]"
},
"successTemplate": "{ \"keyringList\": ${values} }"
}
},
"contract": {
"input": {
"inputSchema": {
"title": "Customer Master Search",
"type": "object",
"properties": {
"keyword": {
"type": "string"
}
},
"additionalProperties": true
}
},
"output": {
"successSchema": {
"title": "keyringList",
"type": "object",
"properties": {},
"additionalProperties": true
}
}
},
"secure": false
}
and here is the translationmapping
{
"translationMap": {
"values": "$..results..keyring"
},
"translationMapDefaults": {
"values": "[]"
},
"successTemplate": "{ \"keyringList\": ${values} }"
}
and here is the raw response
{ "keyringList": [ [ { "customer_id": "7112304016", "supply_chain": "KRN", "status": true }, { "customer_id": "0186274793", "supply_chain": "LEV-CC", "status": true }, { "customer_id": "20182962386", "supply_chain": "BOSS", "status": true } ] ]}
now the problem is that I do have an data action that gives me the values that I want and I am able to set them in participant data in architect. But it's not flattened.....and therefore I can't do anything with it (I believe) because it's a string collection.
please help me out , aldough I think I am nearly there....in the end I hope I can do it all in one data action and then It should look like this :
{ "results": [ { "date_updated": "2020-02-12T15:52:39Z", "customer_id": "7112304016", "contact_phone_number": "+31610", "contact_email_address": "jed@gmail.com", "source_system": "MDM", "business_type": "NP", "address": { "street_name": "Crod", "house_number": "26", "zip_code": "28R", "city": "GO", "country": "NLD" }, "keyring": [ { "customer_id": "7112016", "supply_chain": "KRN", "status": true }, { "customer_id": "0184793", "supply_chain": "LEV-CC", "status": true }, { "customer_id": "20162386", "supply_chain": "BOSS", "status": true } ], "contact_persons": [], "kvk_sync_available": false, "initials": "J.", "last_name": "Sileon", "date_of_birth": "197603", "gender": "MALE", "customer_status": "CUSTOMER", "type": "PERSON", "limited_legal_acting": false } ], "errors": [ { "code": "backend_error", "message": "BOSS" } ]}
many thanks in advance Zubair your help is much appreciated :-)
------------------------------
Jerry Sileon
KPN B.V.
Original Message:
Sent: 06-21-2023 02:02
From: Muhammad Zubair Awan
Subject: Data Action Translation Map
Hi Jerry
Can you share export of your data action? Feel free to DM me if that's easier
------------------------------
Cheers
Zubair
Original Message:
Sent: 06-20-2023 09:51
From: Jerry Sileon
Subject: Data Action Translation Map
Hi Zubair,
I really tried to manage this translation mapping but failed to succeed :(
please have a look at my creation:
{
"translationMap": {"keyringValue": "$.['keyring']"},
"translationMapDefaults": {"keyringValue": ""},
"successTemplate": "{\"keyring\": ${keyringValue}}"
}
output :
based on this raw result from the API like above searching for keyring info :
"results.contact_phone_number": [
"+3161*"
],
"results.address.zip_code": [
"28*"
],
"results.date_updated": [
"2020-02-12T15:52:39Z"
],
"results.address.city": [
"GOUDA"
],
"results.limited_legal_acting": [
false
],
"results.keyring.customer_id": [
[
"71123*",
"01862*",
"201829*"
]
],
"results.keyring.status": [
[
true,
true,
true
]
],
"results.initials": [
"J."
],
"results.contact_email_address": [
"je*r@gmail.com"
],
"results.business_type": [
"NP"
],
"results.source_system": [
"MDM"
],
"results.gender": [
"MALE"
],
"results.keyring.supply_chain": [
[
"KRN",
"LEV-CC",
"BOSS"
cheers and many thanks in advance :-)
best regards Jerry
------------------------------
Jerry Sileon
KPN B.V.
Original Message:
Sent: 06-15-2023 17:44
From: Muhammad Zubair Awan
Subject: Data Action Translation Map
Hi Berry
Are you getting an error like Cannot flatten schemas with nested arrays? AFAIK flattening does not support nested arrays. Do you really need all the data returned or a chunk of it because the other method is to use translationMap in Response to get the data you need. Refer to the examples in this article
------------------------------
Cheers
Zubair
Original Message:
Sent: 06-15-2023 13:52
From: Jerry Sileon
Subject: Data Action Translation Map
Hi Zubair,
great work men , I am trying to understand what it is that makes it when you give me the solution. starting to understand how JSON works with properties and objects, as soon as I hit array whitin arrays (nested I believe) it goes wrong. my last blocker is this thing
"results.contact_phone_number": [
"+3161*"
],
"results.address.zip_code": [
"28*"
],
"results.date_updated": [
"2020-02-12T15:52:39Z"
],
"results.address.city": [
"GOUDA"
],
"results.limited_legal_acting": [
false
],
"results.keyring.customer_id": [
[
"71123*",
"01862*",
"201829*"
]
],
"results.keyring.status": [
[
true,
true,
true
]
],
"results.initials": [
"J."
],
"results.contact_email_address": [
"je*r@gmail.com"
],
"results.business_type": [
"NP"
],
"results.source_system": [
"MDM"
],
"results.gender": [
"MALE"
],
"results.keyring.supply_chain": [
[
"KRN",
"LEV-CC",
"BOSS"
please help me out one more time :-)
Best regards
Jerry
------------------------------
Jerry Sileon
KPN B.V.
Original Message:
Sent: 06-14-2023 20:01
From: Muhammad Zubair Awan
Subject: Data Action Translation Map
Hi Jerry
Try this output contract
{ "title": "Output", "type": "object", "properties": { "results": { "type": "array", "items": { "title": "resultsOutput", "type": "object", "properties": { "contact_email_address": { "type": "string" }, "address": { "type": "object", "properties": { "zip_code": { "type": "string" }, "street_name": { "type": "string" } }, "additionalProperties": true } }, "additionalProperties": true } } }, "additionalProperties": true}
------------------------------
Cheers
Zubair
Original Message:
Sent: 06-14-2023 17:40
From: Jerry Sileon
Subject: Data Action Translation Map
Hi Zubair,
I am struggling to resolve this issue, i try to map it, but the contract keeps giving me an underscore instead of a . (dot)
reason for dot is that is segmented ( i think) in
results.lastname (this succeeds)
results.address.street_name (this one i cant get i right for some reason and it keeps giving an underscore instead . (dot))
please give any advise of how to resolve this issue
best regards
jerry
------------------------------
Jerry Sileon
KPN B.V.
Original Message:
Sent: 06-13-2023 16:18
From: Muhammad Zubair Awan
Subject: Data Action Translation Map
Hi @Jerry Sileon without looking at the API or the complete data structure, I believe that following Output Contract should work. If this does not work can you share the full JSON response (remove any sensitive data) or the API you are using (if its platform API or public API) or the source data structure (remove any sensitive data)
{ "title": "Output", "type": "object", "properties": { "results": { "type": "array", "items": { "title": "resultsOutput", "type": "object", "properties": { "contact_email_address": { "type": "string" } }, "additionalProperties": true } } }, "additionalProperties": true}
------------------------------
Cheers
Zubair
Original Message:
Sent: 06-13-2023 09:59
From: Jerry Sileon
Subject: Data Action Translation Map
------------------------------
Jerry Sileon
KPN B.V.
Original Message:
Sent: 06-13-2023 09:56
From: Jerry Sileon
Subject: Data Action Translation Map
Hi Muhammad Zubair Awan , could you help me as well with this issues , I have verymuch simular use case?
I am getting correct JSON response but none of the output contracts gets filled.
------------------------------
Jerry Sileon
KPN B.V.
Original Message:
Sent: 11-24-2022 14:06
From: Muhammad Zubair Awan
Subject: Data Action Translation Map
Hi,
Leaving the translation map as default, following output contract should work mapping the values
{
"title": "Output",
"type": "object",
"properties": {
"data": {
"type": "object",
"properties": {
"first_name": {
"type": "string"
},
"last_name": {
"type": "string"
},
"avatar": {
"type": "string"
}
},
"additionalProperties": true
}
},
"additionalProperties": true
}
Cheers
------------------------------
Muhammad Zubair Awan
Spark NZ Trading
Original Message:
Sent: 11-24-2022 08:29
From: Hanife Nur Ãzçetin
Subject: Data Action Translation Map
Hi,
Thank you for the reply. I see your point. I changed my request url to this --> https://reqres.in/api/users/${input.id}
Right now While response like below
{
"translationMap": {},
"translationMapDefaults": {},
"successTemplate": "${rawResult}"
}
It receives the correct information about the input id I get without output contracts.
The problem is now when I arranged output contracts like this;
{
"title": "data",
"type": "object",
"properties": {
"first_name": {
"type": "string"
},
"last_name": {
"type": "string"
}
},
"additionalProperties": true
}
It receives correct json but doesn't fill the output template. I tried to add arrays and first_name : $.first_name kind of solutions however it respond an error or remained the same. Do u have any suggestions?
Thank you in advance.
------------------------------
Hanife Nur Ãzçetin
Customer Experience Yazilim Danismalik Ticaret LTD
Original Message:
Sent: 11-23-2022 16:48
From: Muhammad Zubair Awan
Subject: Data Action Translation Map
Hi,
The example in my previous comment was just to show you how to define the JSON path for the values you are trying to read. You were supposed to replace $.id with the fields you are trying to read in your source data - error "No results for path: $['id']" means in your source data, system could not find id under $. path.
Now that I have the API/data you are trying to access, I see that your user data is an array. so for example if you need to read the first_name from element 0 of the data array which is something like
{"data":[{"id":7,"email":"XXXXXX@example.com","first_name":"Michael","last_name":"XXXXXX","avatar":"https://XXXXX/7-image.jpg"}
your translation map will be as below, where first_name is defined as output contract with type string.
{
"translationMap": {
"first_name":"$.data[0].first_name"
},
"translationMapDefaults": {},
"successTemplate": "{\"first_name\": ${first_name}}"
}
it will return "Michael". Similarly you can retrieve other values as you need.
So above should resolve the errors. However, I see that you are taking id (number) as input and trying to retrieve the user details matching that id from the array. I do not think you can do so within the Data Action itself with this GET api. I suggest reading complete data array and extract the data based on the id using the architect flow.
To read the first_name array, change the output contract to
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"type": "object",
"properties": {
"first_name": {
"type": "string"
}
},
"additionalProperties": true
}
}
},
"additionalProperties": true
}
and leave the translation map to default config
{
"translationMap": {},
"translationMapDefaults": {},
"successTemplate": "${rawResult}"
}
similarly you can read other values like last_name, avatar, id etc.
Cheers
------------------------------
Muhammad Zubair Awan
Spark NZ Trading
Original Message:
Sent: 11-23-2022 01:29
From: Hanife Nur Ãzçetin
Subject: Data Action Translation Map
Hi,
My configuration ;
{
"requestUrlTemplate": "https://reqres.in/api/users?page=2",
"requestType": "GET",
"headers": {},
"requestTemplate": "${input.rawRequest}"
}
I tried both of the suggestions but the error is the same.
9. Resolve translation map: Failed while processing the translation map. Could not resolve value for the key: 'userId' and no default value was configured. Additional details: No results for path: $['id'].
------------------------------
Hanife Nur Ãzçetin
Customer Experience Yazilim Danismalik Ticaret LTD
Original Message:
Sent: 11-22-2022 16:03
From: Muhammad Zubair Awan
Subject: Data Action Translation Map
Hi Hanife,
The JSON path for translation map values $first_name, $last_name, and $avatar look incorrect - that is why you are getting the error Illegal character at position 1 expected '.' or '[' - also you haven't defined the success template. You need to define the correct JSON path for the translation map values which you will need to find from the (Response) body of the API you are calling. You have only shared the contracts and not the config so can't tell you the exact path without knowing the API you are using but as an example if you need to read id and name from below JSON
{
"id": "1111-2222-3333-4444",
"name": "Jack Sparrow"
}
then your translation map should be as below - where userId and userName are your output contracts
{
"translationMap": {
"userId": "$.id",
"userName": "$.name"
},
"translationMapDefaults": {},
"successTemplate": "{\"userId\": ${userId},\"userName\": ${userName}}"
}
Hope this helps.
Cheers
------------------------------
Muhammad Zubair Awan
Spark NZ Trading
Original Message:
Sent: 11-21-2022 10:51
From: Hanife Nur Ãzçetin
Subject: Data Action Translation Map
Hello,
I am working on my integration action information. I am trying to create a custom action by taking id as input and from that I am going to get user info such as avatar and first/last name of the user.
INPUT CONTRACT
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "User Info Request",
"description": "Fields needed in the body of the POST to create a calendar reminder.",
"type": "object",
"required": [
"id"
],
"properties": {
"id": {
"type": "number"
}
},
"additionalProperties": true
}
OUTPUT CONTRACT
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "data",
"description": "",
"type": "object",
"properties": {
"avatar": {
"type": "string"
},
"first_name": {
"type": "string"
},
"last_name": {
"type": "string"
}
},
"additionalProperties": true
}
RESPONSE
{
"translationMap": {
"first_name": "$first_name",
"last_name": "$last_name",
"avatar": "$avatar"
},
"translationMapDefaults": {},
"successTemplate": "${rawResult}"
}
When I try to test I got an error which is :
Resolve translation map: Failed while processing the translation map. Could not resolve value for the key: 'first_name' and no default value was configured. Additional details: Illegal character at position 1 expected '.' or '['What I do wrong? I am new at coding. Any help would be appreciated.
Sincerely,
#Integrations
------------------------------
Hanife Nur Ãzçetin
Customer Experience Yazilim Danismalik Ticaret LTD
------------------------------