This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Working with Comments in Box
Overview
The following operations allow you to work with comments. Click an operation name to see details on how to use it.
For a sample proxy service that illustrates how to work with comments, see Sample configuration.
Operation | Description |
---|---|
Adds a comment. | |
deleteComment | Deletes a comment. |
getComment | Retrieves comment details. |
updateComment | Updates a comment. |
Operation details
This section provides details on each of the operations.
Creating a comment
The createComment
operation allows a user to add a comment to a specific file or comment as a reply comment.
<box.createComment> <itemType>{$ctx:itemType}</itemType> <itemId>{$ctx:itemId}</itemId> <message>{$ctx:message}</message> </box.createComment>
Properties
itemType:
Required - The type of the item that this comment will be placed on. It can be a file or a comment.itemId:
Required - The ID of the item that this comment will be placed on.message:
Required - The text body of the comment.
Sample request
Following is a sample REST request that can be handled by the createComment
operation.
{ "apiUrl":"https://api.box.com", "accessToken":"Q3ajlCrUEgkwC6le9rpddffsXaRxndfgAK79dSSz", "itemType":"file", "itemId":"16806754267", "message":"Tested" }
Related Box documentation
http://developers.box.com/docs/#comments-add-a-comment-to-an-item
Deleting a comment
The deleteComment
operation permanently deletes a comment.
<box.deleteComment> <commentId>{$ctx:commentId}</commentId> </box.deleteComment>
Properties
commentId
: The ID of the comment to delete.
Sample request
Following is a sample REST request that can be handled by the deleteComment
operation.
{ "apiUrl":"https://api.box.com", "accessToken":"iItGu0aVqL6qyR2dfgTdfwr9dn7RCTLU7iXxDx", "commentId":"31678149" }
Related Box documentation
http://developers.box.com/docs/#comments-delete-a-comment
Retrieving comment details
The getComment
operation is used to retrieve the messages and metadata about a specific comment. It also includes information on the user who created a comment.
<box.getComment> <commentId>{$ctx:commentId}</commentId> </box.getComment>
Properties
commentId:
ID of the comment.
Sample request
Following is a sample REST request that can be handled by the getComment
operation.
{ "apiUrl":"https://api.box.com", "accessToken":"iItGu0aVqL6qyR2Twrsfdgdf9n7RCTLU7iXxDx", "commentId":"31678149" }
Related Box documentation
http://developers.box.com/docs/#comments-get-information-about-a-comment
Updating a comment
The updateComment
operation allows you to update the message of a comment.
<box.updateComment> <message>{$ctx:message}</message> <commentId>{$ctx:commentId}</commentId> </box.updateComment>
Properties
message:
Required - The text for the comment message.commentId:
ID of the comment.
Sample request
Following is a sample REST request that can be handled by the updateComment
operation.
{ "apiUrl":"https://api.box.com", "accessToken":"G0P4x7Ky6aJF3df8lbdfdfgL0QADJBZbcTs6b1f", "commentId":"31678149", "message":"Updated via ESB" }
Related Box documentation
http://developers.box.com/docs/#comments-change-a-comments-message
Sample configuration
Following is a sample proxy service that illustrates how to connect to Box with the init
operation and use the createComment
operation to list the changes the user made. The sample request for this proxy can be found in createComment sample request. You can use this sample as a template for using other operations in this category.
As a best practice, create a separate sequence for handling the response payload for errors. In the following sample, this sequence is "faultHandlerSeq". For more information, see Configuring the Box Fault Handler Sequence.
<?xml version="1.0" encoding="UTF-8"?> <proxy xmlns="http://ws.apache.org/ns/synapse" name="box_createComment" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> <target> <inSequence onError="faultHandlerSeq"> <property name="apiUrl" expression="json-eval($.apiUrl)"/> <property name="accessToken" expression="json-eval($.accessToken)"/> <property name="fields" expression="json-eval($.fields)"/> <property name="itemType" expression="json-eval($.itemType)"/> <property name="itemId" expression="json-eval($.itemId)"/> <property name="message" expression="json-eval($.message)"/> <box.init> <accessToken>{$ctx:accessToken}</accessToken> <apiUrl>{$ctx:apiUrl}</apiUrl> <fields>{$ctx:fields}</fields> </box.init> <box.createComment> <itemType>{$ctx:itemType}</itemType> <itemId>{$ctx:itemId}</itemId> <message>{$ctx:message}</message> </box.createComment> <property name="messageType" value="application/json" scope="axis2"/> <filter source="$axis2:HTTP_SC" regex="^[^2][0-9][0-9]"> <then> <property name="ERROR_CODE" expression="$axis2:HTTP_SC"/> <switch source="$axis2:HTTP_SC"> <case regex="401"> <property name="ERROR_MESSAGE" value="Unauthorized"/> <property name="error_description" expression="json-eval($.message)"/> <sequence key="faultHandlerSeq"/> </case> </switch> </then> </filter> <respond/> </inSequence> <outSequence> <send/> </outSequence> </target> <description/> </proxy>