Search code examples
azure-data-factoryazure-synapse

Azure Data Factory copy activity with json data


I am using a copy activity with request method as POST to copy the JSON response from a rest api. The rest api requires a body which contains date and time details in the below format

[ { "start_date": "2023-02-07" "start_time": "06:42:06" "end_date": "2023-02-07" "end_time": "08:47:06"

} ]

When am using the date and time as hardcoded values like the one shown above, it works fine. When I try to make it dynamic i.e. startdate as currentdate - 1 and start time as current time - 24hrs and end date as currentdate and end time as current time its failing. In simple words I want to make the body of the api as dynamic

I tried the end date as "{@formatdatetime(utcnow(),'yyyy-MM-dd')}" and end time as end time as "{@formatdatetime(utcnow(),'hh-MM-ss')}"

and few other combinations of the above code but its failing. Can someone please help me with this issue.


Solution

  • Used a set variable activity to create the dynamic date & time separately and then used the output of the variable in the body of copy activity.