Upload via API?

One year later, I am still trying to upload an "update" to a resource.

I attempt to upload an attachment whose type is resource_version using the attachments/new-key API. This is the error I get, even though the docs say context isn't required:
Code:
{
  "errors": [
    {
      "code": "required_input_missing",
      "message": "Required input missing: context",
      "params": {
        "missing": [
          "context"
        ]
      }
    }
  ]
}

I'm guessing I need to reference version_attachment_key somewhere? I really don't know since there's no reference in the docs
 
Context isn't required in all cases, though the case where it's not required is pretty specific. Context is used to ensure that attachment permissions and limits are applied in the expected way. The context can be skipped if you're bypassing permissions, though I think there might actually be a bug there that I need to look into. I'd recommend passing the context, even if you do choose to bypass permissions.

The expected context for an attachment when creating a new resource would be context[resource_category_id] with the ID of the category you're creating the resource in as the value. (The content type would be resource_version for the file itself; if you're trying to add screenshots to the description, resource_update.)

Note that if you're trying to add a new version/create a new resource update to an existing resource the context would be context[resource_id] with the relevant resource ID. (Generally speaking, attachment contexts always use the most specific bit of data we have at the time, since we're uploading attachments before the related content has actually been inserted.)
 
Top Bottom