Is it possible to pass an array (of objects) as an input payload to External Call REST API Transformation in Dataflow?

Anantharaman Rajagopal 0 Reputation points
2025-03-19T17:38:18.1733333+00:00

I am trying to send an array of objects in below format to externalcall to a RESTAPI

[{"abc":"v1","cde":"value2"},{"abc":"v4","cde":"v5"},{"abc":"v7","cde":"v8"}]

However I encounter 2 issues in Externalcall transformation step

  1. The list of objects within the array is taken as a string. How can it be changed to array of objects?

Below is the data copied from Copy request payload

Uri: https://xxx.sdfdgfg.xxx/xxx/rest/xxx/test

Method: POST

Headers: content-type: application/json | Authorization: ******

Body: {"req_array":["{"abc":"v1","cde":"v2"},{"abc":"v4","cde":"v5"},{"abc":"v7","cde":"v8"}"]}

  1. The request body being sent always prefix the columnname (req_array) within the request, due to which I get unknown JSON keyword encountered error response from API.

Below sample error response.

{"status":"error","reason":"Unknown JSON keyword encountered. Valid keywords for the test request are abc and cde."}

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,433 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. J N S S Kasyap 1,525 Reputation points Microsoft External Staff
    2025-03-19T21:04:15+00:00

    Hi @Anantharaman Rajagopal

    The array is currently being treated as a string. Because the square brackets inside req_array indicate that the array is being treated as a string rather than a JSON array. To fix this, use the toJSON() function in a Derived Column transformation before passing the data to the External Call transformation.
    In the Derived Column transformation, apply:

    toJSON(yourColumnName)
    
    

    This ensures the column retains its JSON structure instead of being converted to a string.

    The Flatten transformation in ADF Data Flow to break the array into individual rows, ensuring each object is processed separately. Then, apply the Aggregate transformation to regroup the data into a JSON array without adding a column name, preserving the correct API payload structure.
    The below Microsoft docs will be helpful for reference

    https://learn.microsoft.com/en-us/azure/data-factory/data-flow-expression-functions#tojson
    https://learn.microsoft.com/en-us/azure/data-factory/data-flow-aggregate
    https://learn.microsoft.com/en-us/azure/data-factory/data-flow-flatten
    https://www.youtube.com/watch?v=PieRpstpRJg
    Disclaimer: This response contains a reference to a third-party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    I hope this information helps. Please do let us know if you have any further queries.

    Kindly consider upvoting the comment if the information provided is helpful. This can assist other community members in resolving similar issues.

    Thank you.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.