I’ve been working with this new GraphQL API to automate what I thought would be a simple task, but I seem to be running into what I assume is a silly mistake on my part. I need to create some issues in bulk based on data parsed from different sources, so I started this in Python using the gql library. That didn’t work, I hopped over to the Explorer and I get the same error.
Here is the basic mutation:
mutation createIssue($repoID: ID!) {
createIssue(
input: {
title: "gql test issue",
body: "gql test body",
repositoryId: $repoID,
labels: [
"test label"
]
}
)
{
issue {
id
title
}
}
}
I’m passing in the repoID variable as well
{
"repoID": "100961395"
}
The error message is:
{
"data": {
"createIssue": null
},
"errors": [
{
"message": "Invalid global id: Make sure id is in Base64 format",
"locations": [
{
"line": 2,
"column": 9
}
],
"path": [
"createIssue"
]
}
I use the same repoID in my queries, so I know it can find the correct GH repo in my ZH workspace, but it is a no-go for this mutation. Converting it to base64 throws a different error that I won’t muddy the waters with.
The repositoryID you shared does look incorrect to me, it should be a longer base64 string. As an example, here is the repositoryID for one of my repos Z2lkOi8vcmFwdG9yL1JlcG9zaXRvcnkvMTMzMDQ5Mzgx
Can you try running this query to find your workspace and return all of the associated Repositories and their IDs, that should give you the correct ID to use for a given repo in your query.
query {
viewer {
id
searchWorkspaces(query: "WORKSPACE_NAME") {
nodes {
id
name
repositoriesConnection {
nodes {
id
name
}
}
}
}
}
}
Hi,
Thanks for responding! The query you provided does run successfully and I do get an output. Maybe I should make this question more simple. What is the repositoryId that the createIssue input is expecting? Is it the Github repo ID? Or something different?
I tried to sub this into my mutation, but not only did it not work (error below), but I also don’t understand what it is. I have multiple repos attached to this workspace and I need to be able to pass something to the input to indicate which GH repo to create the issue in.
I took at look at the new query you sent, I decoded the value you used for the ID in the query and this is actually your userID in Zenhub, not the repositoryID.
The value itself for the repositoryID is a Zenhub value, not a Github one. If you were able to run the workspace search query I shared, you should have gotten the repo ID returned to you.
Hi Joseph,
I’ll take the big mea culpa on this one. When I ran the query you provided, I totally didn’t replace WORKSPACE_NAME with my…workspace name. Now that it is set correctly, I do get the proper list of Zenhub repositoryID and plugging that into the mutation creates the issue.
One last question in this thread…is it possible to set the Epic in the same mutation that creates the issue? Based on what I see in the schema, I think it is only the 5 things you can set (title, body, assignees, labels, repoID), but maybe I am missing a way to do it.