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'
IncludeFile "CkJsonObject.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkRest.pb"
Procedure ChilkatExample()
rest.i = CkRest::ckCreate()
If rest.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i
; URL: https://your-domain.atlassian.net/rest/api/2/issue
bTls.i = 1
port.i = 443
bAutoReconnect.i = 1
success = CkRest::ckConnect(rest,"your-domain.atlassian.net",port,bTls,bAutoReconnect)
If success <> 1
Debug "ConnectFailReason: " + Str(CkRest::ckConnectFailReason(rest))
Debug CkRest::ckLastErrorText(rest)
CkRest::ckDispose(rest)
ProcedureReturn
EndIf
CkRest::ckSetAuthBasic(rest,"jira@example.com","JIRA_API_TOKEN")
json.i = CkJsonObject::ckCreate()
If json.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckUpdateString(json,"fields.project.id","10000")
CkJsonObject::ckUpdateString(json,"fields.summary","something is wrong")
CkJsonObject::ckUpdateString(json,"fields.issuetype.id","10000")
CkJsonObject::ckUpdateString(json,"fields.assignee.name","matt")
CkJsonObject::ckUpdateString(json,"fields.priority.id","3")
CkJsonObject::ckUpdateString(json,"fields.labels[0]","bugfix")
CkJsonObject::ckUpdateString(json,"fields.labels[1]","blitz_test")
CkJsonObject::ckUpdateString(json,"fields.description","description")
CkJsonObject::ckUpdateString(json,"fields.fixVersions[0].id","10001")
CkJsonObject::ckUpdateString(json,"fields.customfield_10005","blah blah")
CkRest::ckAddHeader(rest,"Content-Type","application/json")
CkRest::ckAddHeader(rest,"Accept","application/json")
sbRequestBody.i = CkStringBuilder::ckCreate()
If sbRequestBody.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckEmitSb(json,sbRequestBody)
sbResponseBody.i = CkStringBuilder::ckCreate()
If sbResponseBody.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkRest::ckFullRequestSb(rest,"POST","/rest/api/2/issue",sbRequestBody,sbResponseBody)
If success <> 1
Debug CkRest::ckLastErrorText(rest)
CkRest::ckDispose(rest)
CkJsonObject::ckDispose(json)
CkStringBuilder::ckDispose(sbRequestBody)
CkStringBuilder::ckDispose(sbResponseBody)
ProcedureReturn
EndIf
respStatusCode.i = CkRest::ckResponseStatusCode(rest)
If respStatusCode >= 400
Debug "Response Status Code = " + Str(respStatusCode)
Debug "Response Header:"
Debug CkRest::ckResponseHeader(rest)
Debug "Response Body:"
Debug CkStringBuilder::ckGetAsString(sbResponseBody)
CkRest::ckDispose(rest)
CkJsonObject::ckDispose(json)
CkStringBuilder::ckDispose(sbRequestBody)
CkStringBuilder::ckDispose(sbResponseBody)
ProcedureReturn
EndIf
jsonResponse.i = CkJsonObject::ckCreate()
If jsonResponse.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckLoadSb(jsonResponse,sbResponseBody)
id.s
key.s
self.s
id = CkJsonObject::ckStringOf(jsonResponse,"id")
key = CkJsonObject::ckStringOf(jsonResponse,"key")
self = CkJsonObject::ckStringOf(jsonResponse,"self")
CkRest::ckDispose(rest)
CkJsonObject::ckDispose(json)
CkStringBuilder::ckDispose(sbRequestBody)
CkStringBuilder::ckDispose(sbResponseBody)
CkJsonObject::ckDispose(jsonResponse)
ProcedureReturn
EndProcedure
{
"id": "10023",
"key": "SCRUM-24",
"self": "https://chilkat.atlassian.net/rest/api/2/issue/10023"
}