Issue
i have a script
Date date = new Date()
String datePart = date.format("yyyy-MM-dd HH:mm:ss")
sh "curl 'www.link.com' --json '{"datas": "${datePart}"}'"
result is negative...
Ideally result should be curl 'www.link.com' --json '{"datas": "2021-04-07 13:00:00"}'
How could i fix it? i need all quotes to be like in my example and important is that variable should work
Solution
I just tried this it should work so use it like this
sh "curl 'www.link.com' --json \'{\"datas\": \"${datePart}\"}'"
OR another alternatives
"curl 'www.link.com' --json \"{\\\"datas\\\": \\\"${datePart}\\\"}\""
Answered By - Dashrath Mundkar
Answer Checked By - Gilberto Lyons (JavaFixing Admin)