PureBasic Jira - Issues: Assign Issue

Back to Index

Assigns the issue to the user. Use this resource to assign issues for the users having “Assign Issue” permission, and not having the “Edit Issue” permission. If name body parameter is set to “-1” then automatic issue assignee is used. A name set to null will remove the assignee. A successful response is indicated by a 204 status code with no response body. This example assigns issue "SCRUM-15" to "matt"

Documentation: https://developers.atlassian.com/cloud/jira/platform/rest/#api-api-2-issue-issueIdOrKey-assignee-put

CURL Command

curl -X PUT --user jira@example.com:JIRA_API_TOKEN \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '
    {
      "name": "matt"
    }' \
  --url 'https://your-domain.atlassian.net/rest/api/2/issue/SCRUM-15/assignee'

PureBasic Example

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/SCRUM-15/assignee
    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,"name","matt")

    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,"PUT","/rest/api/2/issue/SCRUM-15/assignee",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



    CkRest::ckDispose(rest)
    CkJsonObject::ckDispose(json)
    CkStringBuilder::ckDispose(sbRequestBody)
    CkStringBuilder::ckDispose(sbResponseBody)


    ProcedureReturn
EndProcedure