Fixed RestApi: Misleading error when creating an attachment for a new conversation with no permission


Dear friends,

I'm having a problem when trying to post the first attachment for a conversation. I follow an analogous process when posting the first attachment for a new thread. When posting a new thread with attachments, I upload all the attachments before. The first attachment returns a key, this key is used to upload the next attachments, and finally, the key is passed when posting the post.

I try to do the same when starting a conversation. But in this case, I receive the following error message when uploading the first attachment:

code": "required_input_missing",
"message": "Falta la entrada requerida: context",
"params": {
"missing": [

Indeed, I didn't pass the context as a parameter. When uploading the first attachment for a new thread, I use as context "context[node_id] -> IdOfTheNode", but in the case of the first attachment for a new conversation, I have no idea what for a context is expected.

May somebody point me in the right direction?

Thanks a lot!
No context should be required in this scenario. I think the error message is misleading in this particular circumstance as it's guessing that an empty context means that it failed because the context was lacking. In reality here (since no context is expected), this is actually indicating a no permission error (the user doesn't have permissions to upload attachments to a conversation).

I will move this to bugs though because that assumption doesn't seem to be globally true (though this might be the only case where it's not).
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.8).

Change log:
When requesting a new attachment key and hitting a permission error, make the error more clear.
There may be a delay before changes are rolled out to the XenForo Community.
There wasn't really a clear and reasonable solution to this given that we can't necessarily know whether a context is required or not so I have instead opted for a clearer, but less specific error message:

return $this->noPermission('No permission to manage attachments or no context set.');

If the attachment handler returns a specific error message, this is included too.
Top Bottom