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 New ChilkatRest
Dim success As Long
' URL: https://your-domain.atlassian.net/rest/api/2/issue
Dim bTls As Long
bTls = 1
Dim port As Long
port = 443
Dim bAutoReconnect As Long
bAutoReconnect = 1
success = rest.Connect("your-domain.atlassian.net",port,bTls,bAutoReconnect)
If (success <> 1) 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 New ChilkatJsonObject
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 New ChilkatStringBuilder
success = json.EmitSb(sbRequestBody)
Dim sbResponseBody As New ChilkatStringBuilder
success = rest.FullRequestSb("POST","/rest/api/2/issue",sbRequestBody,sbResponseBody)
If (success <> 1) Then
Debug.Print rest.LastErrorText
Exit Sub
End If
Dim respStatusCode As Long
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 New ChilkatJsonObject
success = jsonResponse.LoadSb(sbResponseBody)
Dim id As String
Dim key As String
Dim self As String
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"
}