Edit issue API -> "update" operations for Attachment field

Hi Team,
I was doing a little research on how to avoid some unnecessary calls while editing an issue and decided to dig into the “update” options that can be passed in the edit issue body.

You can find some examples for certain fields, but not everything is documented.

The list of operations for each field can be found in edit meta:/rest/api/3/issue/{issueKey}/editmeta

Example for labels:

 "labels": {
      ...
      "operations": [
        "add",
        "set",
        "remove"
      ]
},

I’ve tested all of these operations for Labels and Multi-Select, and they work as expected.

Next, I noticed operations for Attachments and Linked Issues:

  "attachment": {
      ...
      "operations": [
        "set",
        "copy"
      ]
  },
  "issuelinks": {
      ...
      "operations": [
        "add",
        "copy"
      ]
    },

So, I wonder if the “copy” operation could work or if it is a relic of the past (which doesn’t seem to be the case, as it is mentioned in several places in the documentation and is returned by the api).

I tried blindly to find something that might work, e.g.:

"update": {
    "attachment": [{"copy": { "from": "WPF-3"}}]
}

However, I always get:

{
    "errorMessages": [],
    "errors": {
        "attachment": "Unrecognized field \"from\" (Class com.atlassian.jira.issue.fields.rest.json.beans.AttachmentsCopyRequestJsonBean), not marked as ignorable\n at [Source: N/A; line: -1, column: -1] (through reference chain: com.atlassian.jira.issue.fields.rest.json.beans.AttachmentsCopyRequestJsonBean[\"to\"])"
    }
}

Does anyone know how to get it to work? :slight_smile:

Hello @Floating-electron

Does anyone know how to get it to work?

You can’t ‘get it to work’.

Just because the issueLinks field has VALUES that you can copy via an API endpoint, does not mean you can use that same API endpoint to somehow perform an entire attachment copy operation between issues.

That’s just plain old wishful thinking.

If you look at that API endpoint’s documentation, the information about the copy property says:

copy any
The field VALUE to copy from another issue.

Since attachments are not field values, the copy operation can’t apply to it.

The problem with the “copy” operation is that it is only returned for those two fields. I have tested almost all other field types, and the edit meta doesn’t list the “copy” operation for any of them. My understanding is that it is (or was, in the distant past) a special handling operation designed specifically for attachments and links.

I don’t think it works now, however it would be quite interesting to discover such long forgotten feature :smiley:
I even did manage to find property for the copy value, so now I don’t get error. I get 204 status, but it does nothing :smiley:

{ "update": {
    "issuelinks": [{"copy": 
       { "sourceIssues": [{"id": 11494 }] ,"type": {"name": "Blocks"}}
    }]
}}

or for attachments:

{
  "update": {
    "attachment": [{"copy": 
       { "sourceIssues": [{"key": "WPF-2" }] }
    }]
  }
}

Fun

I can’t help any further as I don’t recall any Jira REST API endpoint ever having any ability to directly copy attachments from one issue to another.

The old Java APIs could do it via the AttachmentManager class using copyAttachments, but that’s ancient history now.