Jira Cloud: Create an Issue
See more Jira Examples
Create an issue and capture its key and ID for later requests. First use creation metadata to choose an issue type and discover required fields. The sample assumes the selected project/type permits summary and description without additional required fields; add any required values reported by your site's metadata.
Running the example creates a real issue and can trigger notifications and automation. A successful create returns HTTP 201. If a network failure leaves the outcome uncertain, check Jira before retrying so you do not create a duplicate.
The code uses an Atlassian account email and an API token without scopes with the site URL. For a scoped API token, keep Basic authentication and change baseUrl to https://api.atlassian.com/ex/jira/YOUR_CLOUD_ID. For OAuth2, use that gateway URL, omit Login/Password/BasicAuth, and set http.AuthToken to the access token. See API token authentication and OAuth2 authorization. The account must have permission for the operation; OAuth scopes do not grant additional Jira permissions.
Targets Jira Cloud. Jira Data Center has a separate REST API and may require different paths, authentication, or payloads.
Atlassian REST API documentation
Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loHttp
LOCAL lcBaseUrl
LOCAL loUrl
LOCAL loResp
LOCAL loReply
LOCAL loRequest
lnSuccess = 0
* Assumes Chilkat is unlocked. See Global Unlock Sample.
loHttp = CreateObject('Chilkat.Http')
loHttp.RequireSslCertVerify = 1
loHttp.BasicAuth = 1
* Read these credentials from private application configuration.
loHttp.Login = "YOUR_ATLASSIAN_EMAIL"
loHttp.Password = "YOUR_API_TOKEN"
lcBaseUrl = "https://your-domain.atlassian.net"
loHttp.Accept = "application/json"
loUrl = CreateObject('Chilkat.StringBuilder')
loResp = CreateObject('Chilkat.HttpResponse')
loReply = CreateObject('Chilkat.JsonObject')
loRequest = CreateObject('Chilkat.JsonObject')
loRequest.UpdateString("fields.project.key","PROJECT")
* Use the issue type ID returned for this project, not a universal hard-coded ID.
loRequest.UpdateString("fields.issuetype.id","YOUR_ISSUE_TYPE_ID")
loRequest.UpdateString("fields.summary","Example issue")
* Jira v3 rich text is an Atlassian Document Format (ADF) document.
loRequest.UpdateString("fields.description.type","doc")
loRequest.UpdateInt("fields.description.version",1)
loRequest.UpdateString("fields.description.content[0].type","paragraph")
loRequest.UpdateString("fields.description.content[0].content[0].type","text")
loRequest.UpdateString("fields.description.content[0].content[0].text","An issue created through the REST API.")
loUrl.SetString(lcBaseUrl)
loUrl.Append("/rest/api/3/issue")
lnSuccess = loHttp.HttpJson("POST",loUrl.GetAsString(),loRequest,"application/json",loResp)
IF (loResp.StatusCode = 0) THEN
? "No HTTP response was received. Check connectivity and TLS settings."
RELEASE loHttp
RELEASE loUrl
RELEASE loResp
RELEASE loReply
RELEASE loRequest
CANCEL
ENDIF
IF ((lnSuccess <> 1) OR (loResp.StatusCode < 200) OR (loResp.StatusCode >= 300)) THEN
? "Request failed. HTTP " + STR(loResp.StatusCode)
IF (loResp.StatusCode = 429) THEN
? "Rate limited. Retry-After: " + loResp.GetHeaderField("Retry-After")
ENDIF
* Inspect this response locally; it can contain private Jira data.
? loResp.BodyStr
RELEASE loHttp
RELEASE loUrl
RELEASE loResp
RELEASE loReply
RELEASE loRequest
CANCEL
ENDIF
lnSuccess = loReply.Load(loResp.BodyStr)
IF (lnSuccess <> 1) THEN
? "Expected a JSON object in the response."
RELEASE loHttp
RELEASE loUrl
RELEASE loResp
RELEASE loReply
RELEASE loRequest
CANCEL
ENDIF
IF ((loReply.JsonTypeOf("key") <> 1) OR (loReply.StringOfEquals("key","",1) = 1)) THEN
? "Missing value: key"
RELEASE loHttp
RELEASE loUrl
RELEASE loResp
RELEASE loReply
RELEASE loRequest
CANCEL
ENDIF
? "Created issue: " + loReply.StringOf("key")
? "Issue ID: " + loReply.StringOf("id")
RELEASE loHttp
RELEASE loUrl
RELEASE loResp
RELEASE loReply
RELEASE loRequest