<p>I have the following <a href="https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/" rel="nofollow noreferrer">Kubernets CronJob</a> definition:</p>
<pre><code>apiVersion: batch/v1
kind: CronJob
metadata:
  name: myCronJob
spec:
  schedule: &quot;*/1 * * * *&quot;
  failedJobsHistoryLimit: 1
  successfulJobsHistoryLimit: 1
  jobTemplate:
    spec:
      backoffLimit: 2
      parallelism: 1
      template:
        metadata:
          annotations:
            linkerd.io/inject: disabled
        spec:
          containers:
            - name: myCronJob
              image: curlimages/curl:7.72.0
              env:
                - name: CURRENT_TIME
                  value: $(date +&quot;%Y-%m-%dT%H:%M:%S.%sZ&quot;)
              args:
                - /bin/sh
                - -ec
                - &quot;curl --request POST --header 'Content-type: application/json' -d '{\&quot;Label\&quot;:\&quot;myServiceBusLabel\&quot;,\&quot;Data\&quot;:\&quot;{\'TimeStamp\':\'$(echo $CURRENT_TIME)\'}\&quot;,\&quot;QueueName\&quot;:\&quot;myServiceBusQueue\&quot;}' https://mycronjobproxy.net/api/HttpTrigger?code=mySecretCode&quot;
          restartPolicy: OnFailure
</code></pre>
<p>Notice I pass a dynamic date to <code>curl</code> via an environment variable, as described <a href="https://stackoverflow.com/a/58192064/195964">here</a>.</p>
<p>However, this produces an error at runtime (copied from K9s):</p>
<pre><code>curl: (3) unmatched close brace/bracket in URL position 26:                                                                                                                    
+&quot;%Y-%m-%dT%H:%M:%S.%sZ&quot;)}&quot;,&quot;QueueName&quot;:&quot;myServiceBusQueue&quot;}
                         ^
</code></pre>
<p>I suspect this is likely an issue with combining double- and single quotes and escape characters. The <code>curl</code> command runs fine locally on macOS, but not when deployed using the <code>curlimages/curl:7.72.0</code>. There seems to be some difference in behavior.</p>
<p>On macOS, on my local dev machine, I can run the command like so:</p>
<pre><code>curl --request POST --header &quot;Content-type: application/json&quot; -d &quot;{'Label':'myServiceBusLabel','Data':{'TimeStamp':'$(echo $CURRENT_TIME)'},'QueueName':'myServiceBusQueue'}&quot; https://mycronjobproxy.net/api/HttpTrigger?code=mySecretCode
</code></pre>
<p>Output:</p>
<pre><code>Message was successfully sent using the following params: Label = myServiceBusLabel | Data = {&quot;TimeStamp&quot;: &quot;2023-05-15T15:44:45.1684158285Z&quot;} | QueueName = myServiceBusQueue%
</code></pre>
<p>But when I use that version in my K8s CronJob YAML file, my IDE (JetBrains Rider) says: &quot;Scalar value expected.&quot; It seems like the whole command must be enclosed in double quotes.</p>
<p>What is the correct way to quote/escape this <code>curl</code> command?</p>

leifericf
<p>I have made the necessary changes to your curl below can try it once and let me know :</p>
<pre><code>- “curl --request POST --header ‘Content-type: application/json’ -d \&quot;{\&quot;Label\&quot;:\&quot;myServiceBusLabel\&quot;,\&quot;Data\&quot;:\&quot;{\'TimeStamp\':\'$(echo $CURRENT_TIME)\'}\&quot;,\&quot;QueueName\&quot;:\&quot;myServiceBusQueue\&quot;}\&quot; https://mycronjobproxy.net/api/HttpTrigger?code=mySecretCode”
</code></pre>
<p>AS checked in the YAML Lint it is working fine, attached the screenshot. Can you have a check once and try to replicate it.</p>
<p><a href="https://i.stack.imgur.com/MGad6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MGad6.png" alt="working Yaml" /></a></p>
