Reputation: 5
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.
Upvotes: 0
Views: 360
Reputation: 5
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.
Upvotes: 0
Reputation: 1806
The JSON block which you shared is not a JSON itself , I am wondering as to how this is working when you hardcoded .
I see that you are using @formatdatetime(utcnow(),'hh-MM-ss')
to me it looks like you should use @formatdatetime(utcnow(),'hh-mm-ss'
** MM is for month
** mm is for minute
Upvotes: 0
Reputation: 6114
set variable
activities to demonstrate how to create the required body using dynamic content.addDays()
function to remove 1 day from both current date (1 day) and current time (24 hours and hence 1 day).[ { "start_date": "@{formatDateTime(addDays(utcNow(),-1),'yyyy-MM-dd')}" "start_time": "@{formatDateTime(addDays(utcNow(),-1),'hh:mm:ss')}" "end_date": "@{formatDateTime(utcNow(),'yyyy-MM-dd')}" "end_date": "@{formatDateTime(utcNow(),'hh:mm:ss')}"} ]
Upvotes: 0