Forums

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

create issue by using vba - error 200 - but issue isn't created

Lde Buhr
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 11, 2024

Sub CreateJiraIssue()
Dim xmlhttp As Object
Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")

' JIRA-URL für das Erstellen von Issues
Dim jiraUrl As String
jiraUrl = "https://XXX.atlassian.net/jira/servicedesk/projects/TEST/queues/custom"

' JIRA-Benutzername und API-Token
Dim username As String
Dim apiToken As String
username = "XXX"
apiToken = "XXX"

' JSON-Daten für das neue Issue
Dim postData As String
postData = "{""fields"":{""project"":""Test""}, {" & _
"""key"":""TEST""}," & _
"""summary"":""Test Issue""," & _
"""description"":""This is a test issue created using VBA""," & _
"""issuetype"":{""name"":""Task""}}}"

' Setzen Sie die Anmeldeinformationen
xmlhttp.Open "POST", jiraUrl, False, username, apiToken

' Setzen Sie den Header für JSON-Daten
xmlhttp.setRequestHeader "Content-Type", "application/json"

' Senden Sie die Anfrage
xmlhttp.send postData

' Überprüfen Sie die Antwort
Debug.Print "Statuscode: " & xmlhttp.Status
Debug.Print "Antworttext: " & xmlhttp.statusText
Debug.Print "Antwortinhalt: " & xmlhttp.responseText

' Überprüfen Sie die Antwort
If xmlhttp.Status = 201 Then
MsgBox "Issue wurde erfolgreich erstellt!"
Else
MsgBox "Fehler beim Erstellen des Issues. Status: " & xmlhttp.Status & " - " & xmlhttp.statusText
End If
End Sub

1 answer

0 votes
Dag Atle Stenstad
Community Champion
January 11, 2024

Hi @Lde Buhr and welcome to the Atlassian Community!

Have you authenticated yourself with this code? You probably need a Base64 encode, right? And is the URL for creating an issue not correct as well?

What do these return?

Debug.Print "Status code: " & xmlhttp.Status
Debug.Print "Response text: " & xmlhttp.statusText
Debug.Print "Response content: " & xmlhttp.responseText

I have created an VBA open-source project that you can use for inspiration. You can find the project here. If you add this as an Excel Add-in and include it as a reference, you can create a new Jira issue with the following code:

Dim jiraKey As String
jiraKey = Jira.CreateIssue(project, issueType, summary, description)

Hope this helps! 

Lde Buhr
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 13, 2024

Doesn't help. Sry.


Suggest an answer

Log in or Sign up to answer