Hi team,
I am trying to use a data action which returns JSON Objects and Arrays.
Expected Request:
{
"RequestHeader": {
"EntityCode": "string",
"Language": "string",
"SourceSystem": "string",
"ChannelID": "string",
"MaxRecords": "integer",
"UserID": "string",
"AdminUserID": "string",
"RequestCode": "string",
"SessionID": "string",
"ClientIP": "string",
"ProxyIP": "string",
"IsInternational": "boolean",
"Product": "string"
},
"UserId": "string",
"FieldModification": [
{
"FieldName": "string",
"Type": "string",
"Value": [
"string"
]
}
]
}
Expected response:
{
"ResponseHeader": {
"ReturnCode": "string",
"EntityCode": "string",
"Language": "string",
"SourceSystem": "string",
"ChannelID": "string",
"MaxRecords": "integer",
"HasMoreRecords": "boolean",
"UserID": "string",
"AdminUserID": "string",
"Product": "string",
"RequestCode": "string",
"MessageList": [
{
"MessageID": "string",
"MessageType": "string",
"Backend": "string"
}
]
}
}
And my contracts are:
Request:
{
"type": "object",
"properties": {
"UserId": {
"type": "string"
},
"RequestHeader": {
"type": "object",
"properties": {
"EntityCode": {
"type": "string"
},
"Language": {
"type": "string"
},
"SourceSystem": {
"type": "string"
},
"ChannelID": {
"type": "string"
},
"MaxRecords": {
"type": "integer"
},
"UserID": {
"type": "string"
},
"AdminUserID": {
"type": "string"
},
"RequestCode": {
"type": "string"
},
"SessionID": {
"type": "string"
},
"ClientIP": {
"type": "string"
},
"ProxyIP": {
"type": "string"
},
"IsInternational": {
"type": "boolean"
},
"Product": {
"type": "string"
}
},
"additionalProperties": true
},
"FieldModification": {
"type": "array",
"items": {
"type": "object",
"properties": {
"FieldName": {
"type": "string"
},
"Type": {
"type": "string"
},
"Value": {
"type": "array",
"items": {
"type": "string"
}
}
},
"additionalProperties": true
}
}
},
"additionalProperties": true
}
Response:
{
"type": "object",
"properties": {
"ResponseHeader": {
"type": "string"
},
"MessageIDs": {
"type": "array",
"items": {
"title": "Item 1",
"type": "string"
}
},
"MessageTypes": {
"type": "array",
"items": {
"title": "Item 1",
"type": "string"
}
},
"MessageList": {
"type": "array",
"items": {
"title": "Item 1",
"type": "object",
"properties": {
"MessageID": {
"type": "string"
},
"MessageType": {
"type": "string"
},
"Backend": {
"type": "string"
}
},
"additionalProperties": true
}
}
},
"additionalProperties": true
}
And I have the following templates:
Request:
{
"UserId": "${input.UserId}",
"RequestHeader": {
"EntityCode": "${input.EntityCode}",
"Language": "${input.Language}",
"SourceSystem": "${input.SourceSystem}",
"ChannelID": "${input.ChannelID}",
"MaxRecords": ${input.MaxRecords},
"UserID": "${input.UserID}",
"AdminUserID": "${input.AdminUserID}",
"RequestCode": "${input.RequestCodeHeader}",
"SessionID": "${input.SessionID}",
"ClientIP": "${input.ClientIP}",
"ProxyIP": "${input.ProxyIP}",
"IsInternational": ${input.IsInternational},
"Product": "${input.Product}"
},
"FieldModification": [
{
"FieldName": "${input.FieldName}",
"Type": "${input.Type}",
"Value": [
"${input.Value}"
]
}
]
}
Response:
{
"translationMap": {
"MessageIDs": "$.ResponseHeader.MessageList[*].MessageID",
"MessageTypes": "$.ResponseHeader.MessageList[*].MessageType",
"MessageList" : "$.ResponseHeader.MessageList"
},
"translationMapDefaults": {},
"successTemplate": "{\n \"MessageIDs\": ${MessageIDs}, \n \"MessageTypes\": ${MessageTypes}, \n \n \"MessageList\": ${MessageList} \n, \"rawResult\": ${rawResult} \n}"
}
When I invoke it, I receive:
Validate request body contains simple json (key-value pairs): The request could not be understood by the server due to malformed syntax.
- The value provided in the request body is in the wrong format. Only key-value JSON pairs are supported. Example: {"FirstName" : "Joe", "LastName" : "Williams"}
I'm wondering if it's allowed to send array in the request? Since the visual representation of Contract doesn't allow to select Array, only from JSON I could set it.
When I tried to set up my contract not using an array, but simple strings, It was accepting the request, but the response was not ideal, since it expects the array with object(s) in it, so I'm looking for a way to send it as it is defined in the 'Expected request' part.
Any help would be appreciated.
Regards,
Bence