Formation of API request body in ADF

Karthik Malaiyappan 0 Reputation points

I have to pass below parameters to the request body of the API in addition with URL I have. I am using REST Linked service inside copy activity and I am not able to find a way to do it.

Note : format(i) where i is the list of id which I supposed to loop dynamically to the request body.

payload = "{\"inputs\":[{\"id\":\""+ "{}".format(i) + "\",\"after\":\"string\"}]}"
        headers = {
        'accept': "application/json",
        'content-type': "application/json",
        'authorization': "Bearer "+ private_app_key
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,084 questions
{count} votes

1 answer

Sort by: Most helpful
  1. AnnuKumari-MSFT 29,586 Reputation points Microsoft Employee

    Hi Karthik Malaiyappan ,

    Welcome to Microsoft Q&A platform and thanks for posting your question here

    The customer is trying to pass parameters to the request body of an API using REST Linked service inside copy activity in Azure Data Factory (ADF). They are looking for a way to loop dynamically to the request body.

    In the REST API linked service, you can create a parameter named 'id' and use the same in the base URL and pass the ID values by iterating through Foreach activity and have copy activity within foreach.

    REST API linked service parameterization:

    User's image

    Create the REST API dataset and create a new parameter 'Id' .

    Now, create a sql table or csv file having all the ID values that you want to iterate through and use lookup activity to point to the file.

    Use foreach activity to loop through the output of look up activity . Use copy activity within foreach and use @item().Id as the expression for Id value to be passed for source dataset.

    User's image

    You can add the other properties ie. accept , content-type etc in additional headers .

    Hope it helps. Kindly accept the answer by clicking Accept answer button if it helped. Thankyou