Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Contents
maxLevel3
typeflat

...

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 details

This section provides details on each of the operations.

Anchor
createComment
createComment
 Creating a comment

The createComment operation allows a user to add a comment to a specific file or comment as a reply comment.

Code Block
languagehtml/xml
titlecreateComment
<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.
Anchor
request
request
Sample request

Following is a sample REST request that can be handled by the createComment operation.

Code Block
languagexml
titleSample Request for createComment
{
	"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

Anchor
deleteComment
deleteComment
 Deleting a comment

The deleteComment operation permanently deletes a comment.

Code Block
languagehtml/xml
titledeleteComment
<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.

Code Block
languagehtml/xml
titleSample Request for deleteComment
{
	"apiUrl":"https://api.box.com",
	"accessToken":"iItGu0aVqL6qyR2dfgTdfwr9dn7RCTLU7iXxDx",
	"commentId":"31678149"
}
Related Box documentation

http://developers.box.com/docs/#comments-delete-a-comment

Anchor
getComment
getComment
 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.

Code Block
languagehtml/xml
titlegetComment
<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.

Code Block
languagehtml/xml
titleSample Request for getComment
{
	"apiUrl":"https://api.box.com",
	"accessToken":"iItGu0aVqL6qyR2Twrsfdgdf9n7RCTLU7iXxDx",
	"commentId":"31678149"
}
Related Box documentation

http://developers.box.com/docs/#comments-get-information-about-a-comment

Anchor
updateComment
updateComment
Updating a comment

The updateComment operation allows you to update the message of a comment.

Code Block
languagehtml/xml
titleupdateComment
<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.

Code Block
languagehtml/xml
titleSample Request for updateComment
{
	"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

Anchor
sample
sample

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.

Info

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 /wiki/spaces/CONNECTORS/pages/48464457 Configuring the Box Fault Handler Sequence.

Code Block
languagehtml/xml
titleSample Proxy
<?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>