Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass CloudId to GraphQL mutation

Denis Rousselle September 4, 2024

Hello,


In order to speed up the creation of Jira projects and Confluence spaces, I generated the following mutation:

 

mutation ConfluenceLegacy_createSpace{

    confluenceLegacy_createSpace (

        input: {

            additionalSettings: {

                jiraProject: {

                    jiraProjectKey: "DOAGRAPQLT"

                    jiraProjectName: "GraphQL Test"

                    jiraServerId: "ari:cloud:jira:<cloudID>"

                }

                spaceTypeSettings: {

                    enabledContentTypes: {

                        isBlogsEnabled: true

                        isDatabasesEnabled: true

                        isEmbedsEnabled: true

                        isFoldersEnabled: true

                        isLivePagesEnabled: true

                        isWhiteboardsEnabled: true

                    }

                    enabledFeatures: {

                        isAnalyticsEnabled: true

                        isAppsEnabled: true

                        isAutomationEnabled: true

                        isCalendarsEnabled: true

                        isContentManagerEnabled: true

                        isQuestionsEnabled: false

                        isShortcutsEnabled: true

                    }

                }

            }

            copySpacePermissionsFromSpaceKey: "TEMPLATE"

            initialPermissionOption: COPY_FROM_SPACE

            spaceKey: "DOAGRAPQLT"

            spaceName: "GraphQL Test"

            spaceTemplateKey: "TEMPLATE"

        }

    ) @optIn(to: "ConfluenceLegacyRN")  {

        containsExternalCollaborators

        creatorAccountId

        dataClassificationTags

        defaultClassificationLevelId

        externalCollaboratorAndGroupCount

        externalCollaboratorCount

        hasDefaultClassificationLevel

        homepageId

        id

        isExportEnabled

        key

        name

        status

        totalBlogpostsWithoutClassificationLevelOverride

        totalContentWithoutClassificationLevelOverride

        totalPagesWithoutClassificationLevelOverride

        type

        admins(accountType: CUSTOMER) {

            displayName

            operations {

                operation

                targetType

                links {

                    base

                    context

                }

            }

            permissionType

        }

    }

}

 


But I have an error, the cloud id is missing



{


    "errors": [

        {

            "message": "Cannot route request: cannot extract cloud id",

            "locations": [],

            "extensions": {

                "service": "confluence_legacy",

                "errorSource": "GRAPHQL_GATEWAY",

                "statusCode": 400,

                "agg": {

                    "severity": "NORMAL",

                    "ugcPiiSafe": true

                },

                "classification": "CloudIdIsMissingException"

            }

        }

    ],

    "data": {

        "confluenceLegacy_createSpace": null

    },

    "extensions": {

        "gateway": {

            "request_id": "efc8ca8d15f541c0a28e0359ef62eb04",

            "crossRegion": false,

            "edgeCrossRegion": false

        }

    }

}

 

The GraphQL schema does not appear to require a cloudId field


GraphQL space create.png
Is there a special way to pass the cloud Id when mutating with GraphQL?

I tried several ways and I still get the same error.
Can someone help me?

Thank you

2 answers

0 votes
Oliver Siebenmarck _Polymetis Apps_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 4, 2024

Hi @Denis Rousselle ,

I cannot resist a good GraphQL puzzle, so I spent some time with this. I believe you're not doing anything wrong really, much rather it could be that this particular mutation is not working currently. To quote the documentation:

The field is extremely unstable. It can go through changes at any moment, and its execution can be slow and/or unreliable. Clients should use it with care and at their own risk

While I've found Atlassian's REST APIs to be generally quite stable, even when called 'beta', when they say something is experimental in GraphQL, they really mean it. 

That being said: I believe you're trying to use GraphQL to create a related space in Confluence, let me offer a different solution that might also work for you:

mutation createConfluenceRelationship($fromAri: ID!, $toAri: ID!) {
devOps {
ariGraph {
createRelationships(
input: {
relationships: {
type: "project-documentation-entity",
from: $fromAri,
to: $toAri
}
}
)
{
success
errors {
message
}
}
}
}
}

The $fromAri and $toAri would be Jira and Confluence respectively. Not sure if this is a perfect fit for your case, but hopefully it gets you going into the right direction. 

Best regards,
 Oliver

0 votes
Denis Rousselle September 4, 2024

I wonder if this part of GraphQL is not addressed to Jira Server, it's still strange to have one and the same place to use both versions

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events