Code:
Status = sh(script:""“curl -X POST ${SETUP[‘URL’]} -H “Authorization: Bearer ${API_PASSWORD}” -d \“name=${DowntimeMessage}&start_at=${SETUP[‘DOWNTIME_START_TIME’]}&end_at=${SETUP[‘DOWNTIME_END_TIME’]}&timezone=UTC&tags=${SETUP[‘Detail’][‘EnvTag’]}\””"", returnStdout:true)
Error:
just use multiple d statements
curl -d ‘param1=value’ -d ‘param2=value’ etc
Also watch out for double evaluation inside double quotes, if API_PASSWORD contains $HOME for example, groovy will replace $API_PASWORD, then bash will replace $HOME, if you use single quotes, then only bash evaluates not bash.
Below is error that I am getting after using multiple d statements , I think we can’t use multiple as per statuscake API
oh i’m sorry, -d is data, you want -F for form params
Any other solution ?
Could you try this?
Status = sh(
script: "curl ${SETUP['URL']} -H 'Authorization: Bearer ${API_PASSWORD}' -d name=${DowntimeMessage} -d start_at=${SETUP['DOWNTIME_START_TIME']} -d end_at=${SETUP['DOWNTIME_END_TIME']} -d timezone=UTC -d tags=${SETUP['Detail']['EnvTag']}",
returnStdout:true
)
With -d options curl should merged them together with a separating &-symbol and send data in a POST request to the HTTP server, in the same way that a browser does when a user has filled in an HTML form and presses the submit button. This will cause curl to pass the data to the server using the content-type application/x-www-form-urlencoded.