<p>According to the <a href="https://groovy-lang.org/syntax.html#_maps" rel="nofollow noreferrer">Groovy language docs</a>, when defining a map literal, the keys should not be surrounded by double quotes.  I.e.:</p>
<pre><code>def payload = {
  data: {
    attributes: {
      some_key: &quot;some_value&quot;
    }
  }
}
</code></pre>

CC BY-SA 4.0
2022-10-16T19:15:24.830Z
2022-10-16T19:15:24.830Z
jayhendren
<pre><code>#!groovy


env.BEARER_TOKEN = &quot;uuuuuuuuuu&quot;

node {
    publishModule()
}

def publishModule() {
    stage('Deploy Modules') {
  }
} 
def buildPayload() {
    def payload = 
{
    &quot;data&quot;: {
        &quot;attributes&quot;: {
          &quot;vcs-repo&quot;: {
            &quot;identifier&quot;:&quot;nnnnnn&quot;,
            &quot;oauth-token-id&quot;:&quot;hhhhhh&quot;,
            &quot;display_identifier&quot;:&quot;nnnnnn&quot;
          }
          &quot;no-code&quot;: true
        },
        &quot;type&quot;:&quot;registry-modules&quot;
     }
 }
}

def deployModules() {
    def payload = buildPayload()
    def response = httpRequest(
        customHeaders: [
                [ name: &quot;Authorization&quot;, value: &quot;Bearer &quot; + env.BEARER_TOKEN],
                [ name: &quot;Authorization&quot;, value: &quot;application/vnd.api+json&quot; ]
            ],
        httpMode: 'POST',
        responseBody: &quot;${payload}&quot;,
        url: &quot;https://app.terraform.io/api/v2/organizations/my-organization/registry-modules/vcs&quot;

        
    )
}

       
</code></pre>
<pre><code>WorkflowScript: 17: expecting '}', found ':' @ line 17, column 11.
       &quot;data&quot;: {
             ^
</code></pre>
<p>I am trying to build this code in a Jenkinsfile so I am getting this error.  <strong>WorkflowScript: 17: expecting '}', found ':' @ line 17, column 11.</strong> Any suggestion will be appreciated.</p>

<jenkins><jenkins-pipeline><groovy>
Running this groovy jenkins script output this error "WorkflowScript: 17: expecting '}', found ':' @ line 17, column 11"
green_car
# Running this groovy jenkins script output this error "WorkflowScript: 17: expecting '}', found ':' @ line 17, column 11"

(Asked by: username_0 on 2022-10-15)

#!groovy


env.BEARER_TOKEN = "uuuuuuuuuu"

node {
    publishModule()
}

def publishModule() {
    stage('Deploy Modules') {
  }
} 
def buildPayload() {
    def payload = 
{
    "data": {
        "attributes": {
          "vcs-repo": {
            "identifier":"nnnnnn",
            "oauth-token-id":"hhhhhh",
            "display_identifier":"nnnnnn"
          }
          "no-code": true
        },
        "type":"registry-modules"
     }
 }
}

def deployModules() {
    def payload = buildPayload()
    def response = httpRequest(
        customHeaders: [
                [ name: "Authorization", value: "Bearer " + env.BEARER_TOKEN],
                [ name: "Authorization", value: "application/vnd.api+json" ]
            ],
        httpMode: 'POST',
        responseBody: "${payload}",
        url: "https://app.terraform.io/api/v2/organizations/my-organization/registry-modules/vcs"

        
    )
}

       

WorkflowScript: 17: expecting '}', found ':' @ line 17, column 11.
       "data": {
             ^

I am trying to build this code in a Jenkinsfile so I am getting this error.  WorkflowScript: 17: expecting '}', found ':' @ line 17, column 11. Any suggestion will be appreciated.

**Tags:** jenkins, jenkins-pipeline, groovy


---

## 1 answers

### Answer by username_1 on 2022-10-16. Score: 0

According to the Groovy language docs, when defining a map literal, the keys should not be surrounded by double quotes.  I.e.:
def payload = {
  data: {
    attributes: {
      some_key: "some_value"
    }
  }
}


---

