user3211705
user3211705

Reputation: 2578

Box Api - How to Get user details who commented a file

I have a scenario in Box of commenting a file using Box Api. I have used Box api to add a comment. When displaying all the comments, it shows commented person name same for all comments.

How should I add a comment to differentiate who has commented it using Box API

Sample comment List:

{
    "type": "comment",
    "id": "1111",
    "is_reply_comment": false,
    "message": "Sample Comment 1",
    "created_by": {
      "type": "user",
      "id": "111",
      "name": "AAA",
      "login": "[email protected]"
    },
    "created_at": "2016-08-11T00:01:56-07:00",
    "item": {
      "id": "78110824178",
      "type": "file"
    },
    "modified_at": "2016-08-11T00:01:56-07:00"
}
{
    "type": "comment",
    "id": "2222",
    "is_reply_comment": false,
    "message": "Sample Comment 2",
    "created_by": {
      "type": "user",
      "id": "111",
      "name": "AAA",
      "login": "[email protected]"
    },
    "created_at": "2016-08-11T00:01:56-07:00",
    "item": {
      "id": "78110824178",
      "type": "file"
    },
    "modified_at": "2016-08-11T00:01:56-07:00"
}

Please help to add comments for different users

Upvotes: 1

Views: 100

Answers (1)

Murtza Manzur
Murtza Manzur

Reputation: 1214

To comment as a specific user, you can use the As-User header. Here is an example:

curl https://api.box.com/2.0/comments \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "As-User: USER_ID" \
-d '{"item": {"type": "file", "id": "FILE_ID"}, "message": "YOUR_MESSAGE"}' \
-X POST

Upvotes: 1

Related Questions