(PureBasic) Download a Jira Attachment
Demonstrates how to download a Jira attachment to a file.
IncludeFile "CkHttp.pb"
Procedure ChilkatExample()
; 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.i = 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
|