Robotic Process Automation (RPA)

Robotic Process Automation (RPA)

Come for answers. Stay for best practices. All we’re missing is you.

 View Only
  • 1.  Attach file by API using HTTP Request activity

    Posted Mon April 11, 2022 04:15 AM
    Hello,

    I need some help by attach a file in Jira system using "HTTP Request".
    I need to know which are mandatory "Headers" and "Content Headers" which I  need to use when I try to attach a different type of files using this activity.
    And if it is possible to show me their properties for attaching .txt file to test the example.
    When I try to run activity with parameters I have set the "Reason Phrase" returns: Unsupported Media Type --->error 415


    Thanks for your time :)

    ------------------------------
    IVO STOIMENOV
    ------------------------------


  • 2.  RE: Attach file by API using HTTP Request activity

    Posted Tue April 12, 2022 12:54 PM
    Hi Ivo,

    Check out the code in the library here:

    REST API upload PDF

    Hopefully, this will show you how to do it.

    ------------------------------
    NIGEL CROWTHER
    ------------------------------



  • 3.  RE: Attach file by API using HTTP Request activity

    Posted Wed April 13, 2022 09:27 AM
    Hello Nigel,

    It is a good example to understand how "HTTP Request" works and the way to set needed headers
    but I think that it won't help my problem.
    I ask for help by Jira support and when I have some working update I will share

    Thanks for your time :)

    ------------------------------
    IVO STOIMENOV
    ------------------------------



  • 4.  RE: Attach file by API using HTTP Request activity

    Posted Thu July 28, 2022 03:12 AM
    Hello Nigel,

    We worked with IBM support guys and find decision of problem to attach file in Jira Case.
    I share script here if someone need it :)

    defVar --name multipart --type HttpContent
    defVar --name sucess --type Boolean
    defVar --name cred --type String
    defVar --name dictionary --type StringDictionary --innertype String
    defVar --name fileContent --type HttpContent
    defVar --name response --type String
    defVar --name statusCode --type Numeric
    defVar --name RP --type String
    defVar --name headers --type StringDictionary --innertype String
    defVar --name ContentHeaders --type StringDictionary --innertype String
    strDictAdd --key "X-Atlassian-Token" --value "no-check" --dictionary ${dictionary}
    textToBase64 --source "username:JiraToken" --encoding "UTF8" sucess=success cred=value
    logMessage --message "Success: ${sucess} encoded: ${cred}" --type "Info"
    strDictAdd --key Authorization --value "Basic ${cred}" --dictionary ${dictionary}
    createHttpContent --formattype "Bytes" --file PathToFile fileContent=value
    createHttpContent --formattype "Multipart" --contentlist "file=${fileContent}" multipart=value

    httpRequest
    --verb "Post" --url " https://econtexpress.atlassian.net/rest/api/latest/issue/AO-127217/attachments" --headers ${dictionary} --formatter "Instance" --source "${multipart}" --cookiecontainer  --comment "https://econtexpress.atlassian.net/rest/api/latest/issue/AO-127217/attachments " sucess=success response=value statusCode=statusCode RP=reasonPhrase headers=headers ContentHeaders=contentHeaders

    logMessage --message "\r\n----------------------------------------------\r\nSucess: ${sucess}\r\nResponse: ${response}\r\nStatusCode: ${statusCode}\r\nRP: ${RP}\r\nHeaders: ${headers}\r\nContentHeaders: ${ContentHeaders}\r\n-----------------------------------------------------------" --type "Info"

    ------------------------------
    IVO STOIMENOV
    ------------------------------