How can I insert an image in a task description or comment using the api?

I can create task, comment and attachment using the api.

But I can't figure out how to insert an attachment in the task description or in a comment.

How can I do this?

4
👍 Spot On 💡 Innovative Approach 💪 Stellar Advice ✅ Solved 🪄 Remove Kudos
6 commenti

I'm also interested in a solution. From what I've found, the default way to do this is found here.  An example description text, in html, as pulled from a ticket created in the ui:

<img src="https://storage.www.wrike.com/filemeta/thumb100/IDENTIFIER.CHARACTERS" />

Specifically, I am interested in using already uploaded attachments in the ticket description. I've tried grabbing the link via the api, but it's not correct. The link requested from the API method "Get Access URL for Attachment" found here returns the following:

{
  "kind": "url",
  "data": [
    {
      "url": "https://storage.www.wrike.com/extfile/WRIKE.INTERNAL.IDENTIFIERS/ATTACHMENT.FORMAT"
    }
  ]
}

Using this link in with the previously mentioned syntax notably does not insert the image in the description. Would love to have an answer to this to speed up several processes.

4
👍 Spot On 💡 Innovative Approach 💪 Stellar Advice ✅ Solved 🪄 Remove Kudos
Avatar
Hugh

Hey everyone,

I've raised Support tickets for you here, someone should be in contact with you soon. If you need assistance with anything else, be sure to let me know.

3
👍 Spot On 💡 Innovative Approach 💪 Stellar Advice ✅ Solved 🪄 Remove Kudos

I'm interested in a solution too. Сan anybody help me? How can i get attachment URL for using in a tack description?

0
👍 Spot On 💡 Innovative Approach 💪 Stellar Advice ✅ Solved 🪄 Remove Kudos

@Sardana,

As far as I can tell you'd need to upload the file using the API, check the URL via the app, then use that in your code. It's been about two years since I've tried working with this since Wrike has made no further comments on this aside from a help ticket I submitted saying "this is not on our roadmap" so if you find a workaround, it would be appreciated, but it definitely soured me to using wrike for things like automated reports.

3
👍 Spot On 💡 Innovative Approach 💪 Stellar Advice ✅ Solved 🪄 Remove Kudos

@Silas Meriam Thanks for your feedbacks!)

0
👍 Spot On 💡 Innovative Approach 💪 Stellar Advice ✅ Solved 🪄 Remove Kudos

1. Attach the image to the task.

2. Create the preview-image-name from the attachment ID (see code below).

3. Update the task description - you can use <img src="https://storage.www.wrike.com/filemeta/thumb100/preview-image-name">

/**
 * @description Given a Wrike attachment ID (for an image), return the corresponding
 *              URL that can be used in a Task description to display the image inline.
 * @param {string} id - Wrike attachment ID
 * @returns {string} - image preview URL
 */
function attachmentFilename_fromId(id) {
    const decodedId     = base32Decode(id)
    const hexArray      = []
    for (let i = 0; i < decodedId.length; i++)
        hexArray.push(decodedId[i])
    const account       = (hexArray[1] << 24) | (hexArray[2] << 16) | (hexArray[3] << 8) | (hexArray[4] << 0)
    const attachment    = (hexArray[6] << 24) | (hexArray[7] << 16) | (hexArray[8] << 8) | (hexArray[9] << 0)
    const fileStr       = `F${attachment}.A${account}`
    return fileStr
}

// Helper function to decode Base32 string
function base32Decode(input) {
    const base32Chars   = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"
    const paddingChar   = "="
    let bits            = 0
    let value           = 0
  let output          = []
for (let i = 0; i < input.length; i++) {
        const char = input[i]
        if (char === paddingChar) break

        const index = base32Chars.indexOf(char)
        if (index < 0) throw Error(`Invalid base32 character: "${char}"`)
        value = (value << 5) | index
        bits += 5

        if (bits >= 8) {
            output.push((value >>> (bits - 8)) & 0xFF)
            bits -= 8
        }
    }
    return new Uint8Array(output)
}
1
👍 Spot On 💡 Innovative Approach 💪 Stellar Advice ✅ Solved 🪄 Remove Kudos

Folllowing List for Post: How can I insert an image in a task description or comment using the api?
[this list is visible for admins and agents only]

Su
Didn’t find what you were looking for? Write new post