First of all, create a new API Key Token:

  1. Create an API key:
  2. Combine the key with login name in base64 string, go to 
  3. Format is loginname:API-key exampel: give result: a3Jpc3Rlci5icm9tYW5AYWR2YW5pYS5zZTpBQkNERTEyMzQ1
  4. Combine this with the authentication type in the below case a basic so the full text is: Basic a3Jpc3Rlci5icm9tYW5AYWR2YW5pYS5zZTpBQkNERTEyMzQ1 

Now we are ready to create the Workflow Postfunction with Scriptrunner for Jira Cloud.

import groovy.json.JsonBuilder

def params = [
    key: "TESTCONF",
    name: "Test Confluence",
    description: [
        plain: [
            value: "Space created automatically on " + new Date().format("dd/MMM/yyyy HH:mm"),
            representation: "plain"

HttpResponse<JsonNode> response ="")
      .header("Authorization", "Basic xxx")
      .header("accept", "application/json")
      .header("Content-Type", "application/json")
      .body(new JsonBuilder(params).toString())

Some notes:

Remember to replace xxx in the code by the API Key...

401/403 errors are usually related to permission issues. Using the API key would not be enough, you will need to combine the key with the login name in base64 string for it to be successfully authorized.

By MrAddon.


Posted by:.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s