Sample code for 30+ languages & platforms
PureBasic

Download a Jira Attachment

See more Jira Examples

Demonstrates how to download a Jira attachment to a file.

Chilkat PureBasic Downloads

PureBasic
IncludeFile "CkHttp.pb"

Procedure ChilkatExample()

    success.i = 0

    ; This example requires the Chilkat API to have been previously unlocked.
    ; See Global Unlock Sample for sample code.

    http.i = CkHttp::ckCreate()
    If http.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkHttp::setCkFollowRedirects(http, 1)

    ; Provide the username/password for authentication
    CkHttp::setCkLogin(http, "jira@example.com")
    CkHttp::setCkPassword(http, "JIRA_API_TOKEN")

    ; The URL for a Jira attachment has this format: 
    ; https://your-domain.atlassian.net/secure/attachment/{attachment_id}/{attachment_filename}

    url.s = "https://chilkat.atlassian.net/secure/attachment/10001/starfish.jpg"
    localFilePath.s = "qa_output/starfish.jpg"
    success = CkHttp::ckDownload(http,url,localFilePath)
    If success <> 1
        Debug CkHttp::ckLastErrorText(http)
        CkHttp::ckDispose(http)
        ProcedureReturn
    EndIf

    Debug "Successfully downloaded Jira attachment."


    CkHttp::ckDispose(http)


    ProcedureReturn
EndProcedure