Legacy Dev Forum Posts

 View Only

Sign Up

Custom Data Action with Arrays

  • 1.  Custom Data Action with Arrays

    Posted 06-05-2025 18:26

    lopediusm | 2023-07-03 09:51:12 UTC | #1

    Hello, I have a question please:

    I have a custom data action which retrieves customer information from SAP ECC, the data we are expecting from SAP is as follows: 1. Customer Header information, 2 - Open Orders (array) and 3 - Open deliveries (array). We have noticed that if the array is empty, the data action complains about an "invalid schema"; please see error message below.

    { "message": "JSON failed output schema validation for the following reasons: Schema: # @/properties/ZsdOpenDeliveries/properties/item. Error location: /ZsdOpenDeliveries/item. instance type (object) does not match any allowed primitive type (allowed: [\"array\"])", "code": "invalid.schema", "status": 400, "messageParams": {}, "contextId": "9be8de84-91cb-4d08-b56b-4c20e13dd6fe", "details": [ { "errorCode": "ACTION.PROCESSING" } ], "errors": [] }

    If you check under the data action *Operations -> 10 - Apply Output Transformatio* n, you can see that a successful response was received from SAP with the customer name and number; the data action throws an invalid schema error due to an empty array:

    { "Message": "", "ZsdCustomerHeader": { "CustomerName": "DDD Company", "CustomerNumber": "0000077777", "CreditStatus": 100, "CreditLimitAvailable": 5, "AccountType": "" }, "ZsdOpenDeliveries": { "item": { "PoNumber": "", "SoNumber": "", "DeliveryNumber": "", "BeginDate": "0000-00-00", "EndDate": "0000-00-00", "Status": "" } }, "ZsdOpenOrders": { "item": { "PoNumber": "", "SoNumber": "", "CreatedBy": "", "DateProcessed": "0000-00-00", "OverallStatus": "" } } }

    I am not sure what configurations or settings I need to make in order to prevent this error when the open orders and deliveries arrays are empty

    Your assistance will be highly appreciated.

    Regards, Lopedius


    Jerome.Saint-Marc | 2023-07-03 12:16:57 UTC | #2

    Hello,

    I think it would help if you could post your Output Contract, your Response Configuration.

    And also a sample response with arrays (I mean successful answer where you had non-empty arrays). You mentioned there is an empty array in your sample JSON response - but I don't see any attribute with an array type.

    Regards,


    lopediusm | 2023-07-03 12:44:58 UTC | #3

    Hi Jerome,

    Thanks for your response. Please see my Output contract in JSON format:

    { "type": "object", "properties": { "ZsdOpenDeliveries": { "type": "object", "properties": { "item": { "type": "array", "items": { "type": "object", "properties": { "SoNumber": { "type": "string" }, "PoNumber": { "type": "string" }, "DeliveryNumber": { "type": "string" }, "BeginDate": { "type": "string" }, "EndDate": { "type": "string" }, "Status": { "type": "string" } }, "additionalProperties": true } } }, "additionalProperties": true }, "ZsdOpenOrders": { "type": "object", "properties": { "item": { "type": "array", "items": { "title": "Item 1", "type": "object", "properties": { "PoNumber": { "type": "string" }, "SoNumber": { "type": "string" }, "CreatedBy": { "type": "string" }, "DateProcessed": { "type": "string" }, "OverallStatus": { "type": "string" } }, "additionalProperties": true } } }, "additionalProperties": true }, "ZsdCustomerHeader": { "type": "object", "properties": { "CustomerName": { "type": "string" }, "CustomerNumber": { "type": "string" }, "CreditStatus": { "type": "number" }, "CreditLimitAvailable": { "type": "number" }, "AccountType": { "type": "string" } }, "additionalProperties": true }, "Message": { "type": "string" } }, "additionalProperties": true }

    Below is a sample response where the arrays are not empty:

    { "Message": "", "ZsdOpenDeliveries.item.SoNumber": [ "", "0002083854", "0002083866" ], "ZsdOpenDeliveries.item.PoNumber": [ "", "Opsi 1", "Opsi 4" ], "ZsdOpenOrders.item.OverallStatus": [ "", "Not Yet Processed" ], "ZsdOpenOrders.item.CreatedBy": [ "", "G0548108" ], "ZsdOpenDeliveries.item.BeginDate": [ "0000-00-00", "2023-05-23", "2023-05-29" ], "ZsdCustomerHeader.CreditStatus": 99.99, "ZsdCustomerHeader.CustomerName": "URBAN Brews", "ZsdOpenOrders.item.DateProcessed": [ "0000-00-00", "2023-05-10" ], "ZsdCustomerHeader.CustomerNumber": "0000078888", "ZsdOpenDeliveries.item.DeliveryNumber": [ "", "0082597726", "0082597732" ], "ZsdOpenDeliveries.item.Status": [ "", "Partially Processed", "Partially Processed" ], "ZsdCustomerHeader.CreditLimitAvailable": -7907110.9, "ZsdOpenDeliveries.item.EndDate": [ "0000-00-00", "2023-05-23", "2023-05-29" ], "ZsdOpenOrders.item.SoNumber": [ "", "0002083823" ], "ZsdCustomerHeader.AccountType": "", "ZsdOpenOrders.item.PoNumber": [ "", "gladys sal" ]


    lopediusm | 2023-07-03 13:27:50 UTC | #4

    Hi Jerome,

    I managed to resolve the error by configuring the following translation map, thanks for your willingness to assist.

    { "translationMap": { "ZsdOpenDeliveries": "$.ZsdOpenDeliveries", "ZsdOpenOrders": "$.ZsdOpenOrders", "ZsdCustomerHeader": "$.ZsdCustomerHeader", "Message": "$.Message" }, "translationMapDefaults": {}, "successTemplate": "${rawResult}" }


    system | 2023-08-03 13:28:05 UTC | #5

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 20814