So, I am creating a Copy activity that reads from SQL Server table and have to send the data to an API end point with the PATCH request. API provider specified that the body must be in the form of
"updates":[{"key1":"value1","key2":"value2","key3":"value3" },
{"key1":"value1","key2":"value2","key3":"value3" }, ...
.... {"key1":"value1","key2":"value2","key3":"value3" }]
However, my sql table maps to json this way (without the wrapper 'updates:')
[{"key1":"value1","key2":"value2","key3":"value3" },
{"key1":"value1","key2":"value2","key3":"value3" }, ...
.... {"key1":"value1","key2":"value2","key3":"value3" }]
I use the copy activity with the sink data set being of type Rest ..
How can we modify the mapping, so that schema gets wrapped by "updates" object ?
Using copy data activity, there might not be any possibility to wrap the data (array of objects) to an
updateskey.To do this, I have used a
lookupactivity to get the data,set variableactivity to wrap the data with anupdatesobject key and finally, useWebactivity with PATCH method and above variable value as body to complete the activity.The following is the sample data I have taken for my SQL server table.
look upactivity to select the data from this table using table or query option (I used query option). The debug output would be as follows:NOTE: If your data is not same as in sample table I have taken, try using the query option so the output would be something as shown below
updateskey.Webactivity, choose all the necessary settings (PATCH method, authorizations, headers, URL, etc.,) and give the body as follows (I used a fake REST api as a demo):Web activitydebug input shows what is the body that is being passed to the Rest API. The following is an image for reference: