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 rest As Chilkat.Rest
Set rest = Chilkat.NewRest
' URL: https://your-domain.atlassian.net/rest/api/2/issue
bTls = True
port = 443
bAutoReconnect = True
success = rest.Connect("your-domain.atlassian.net",port,bTls,bAutoReconnect)
If (success <> True) Then
Debug.Print "ConnectFailReason: "; rest.ConnectFailReason
Debug.Print rest.LastErrorText
Exit Sub
End If
success = rest.SetAuthBasic("jira@example.com","JIRA_API_TOKEN")
Dim json As Chilkat.JsonObject
Set json = Chilkat.NewJsonObject
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")
Dim sbRequestBody As Chilkat.StringBuilder
Set sbRequestBody = Chilkat.NewStringBuilder
success = json.EmitSb(sbRequestBody)
Dim sbResponseBody As Chilkat.StringBuilder
Set sbResponseBody = Chilkat.NewStringBuilder
success = rest.FullRequestSb("POST","/rest/api/2/issue",sbRequestBody,sbResponseBody)
If (success <> True) Then
Debug.Print rest.LastErrorText
Exit Sub
End If
respStatusCode = rest.ResponseStatusCode
If (respStatusCode >= 400) Then
Debug.Print "Response Status Code = "; respStatusCode
Debug.Print "Response Header:"
Debug.Print rest.ResponseHeader
Debug.Print "Response Body:"
Debug.Print sbResponseBody.GetAsString()
Exit Sub
End If
Dim jsonResponse As Chilkat.JsonObject
Set jsonResponse = Chilkat.NewJsonObject
success = jsonResponse.LoadSb(sbResponseBody)
id = jsonResponse.StringOf("id")
key = jsonResponse.StringOf("key")
self = jsonResponse.StringOf("self")
{
"id": "10023",
"key": "SCRUM-24",
"self": "https://chilkat.atlassian.net/rest/api/2/issue/10023"
}