Creates an issue or a sub-task from a JSON representation.
curl -X POST --user jira@example.com:JIRA_API_TOKEN \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '
{
"fields": {
"project": {
"id": "10000"
},
"summary": "something is wrong",
"issuetype": {
"id": "10000"
},
"assignee": {
"name": "matt"
},
"priority": {
"id": "3"
},
"labels": [
"bugfix",
"blitz_test"
],
"description": "description",
"fixVersions": [
{
"id": "10001"
}
],
"customfield_10005": "blah blah"
}
}' \
--url 'https://your-domain.atlassian.net/rest/api/2/issue'
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set outFile = fso.CreateTextFile("output.txt", True)
set rest = CreateObject("Chilkat_9_5_0.Rest")
' URL: https://your-domain.atlassian.net/rest/api/2/issue
bTls = 1
port = 443
bAutoReconnect = 1
success = rest.Connect("your-domain.atlassian.net",port,bTls,bAutoReconnect)
If (success <> 1) Then
outFile.WriteLine("ConnectFailReason: " & rest.ConnectFailReason)
outFile.WriteLine(rest.LastErrorText)
WScript.Quit
End If
success = rest.SetAuthBasic("jira@example.com","JIRA_API_TOKEN")
set json = CreateObject("Chilkat_9_5_0.JsonObject")
success = json.UpdateString("fields.project.id","10000")
success = json.UpdateString("fields.summary","something is wrong")
success = json.UpdateString("fields.issuetype.id","10000")
success = json.UpdateString("fields.assignee.name","matt")
success = json.UpdateString("fields.priority.id","3")
success = json.UpdateString("fields.labels[0]","bugfix")
success = json.UpdateString("fields.labels[1]","blitz_test")
success = json.UpdateString("fields.description","description")
success = json.UpdateString("fields.fixVersions[0].id","10001")
success = json.UpdateString("fields.customfield_10005","blah blah")
success = rest.AddHeader("Content-Type","application/json")
success = rest.AddHeader("Accept","application/json")
set sbRequestBody = CreateObject("Chilkat_9_5_0.StringBuilder")
success = json.EmitSb(sbRequestBody)
set sbResponseBody = CreateObject("Chilkat_9_5_0.StringBuilder")
success = rest.FullRequestSb("POST","/rest/api/2/issue",sbRequestBody,sbResponseBody)
If (success <> 1) Then
outFile.WriteLine(rest.LastErrorText)
WScript.Quit
End If
respStatusCode = rest.ResponseStatusCode
If (respStatusCode >= 400) Then
outFile.WriteLine("Response Status Code = " & respStatusCode)
outFile.WriteLine("Response Header:")
outFile.WriteLine(rest.ResponseHeader)
outFile.WriteLine("Response Body:")
outFile.WriteLine(sbResponseBody.GetAsString())
WScript.Quit
End If
set jsonResponse = CreateObject("Chilkat_9_5_0.JsonObject")
success = jsonResponse.LoadSb(sbResponseBody)
id = jsonResponse.StringOf("id")
key = jsonResponse.StringOf("key")
self = jsonResponse.StringOf("self")
outFile.Close
{
"id": "10023",
"key": "SCRUM-24",
"self": "https://chilkat.atlassian.net/rest/api/2/issue/10023"
}