Act on a community file that is awaiting approvalTo programmatically take action on a community file that is waiting to be approved, send an Atom entry document that defines the action you want to take to the moderation action feed.
Only the moderator can take action on a file awaiting approval.
See Authenticating requests for information about how to authenticate the request.
To take action on a file awaiting approval...
- Retrieve the moderation service document. See Retrieve the Files moderation service document for more details.
- In the service document, locate the workspace with the <category term="documents-moderation" .../> child element, and then find the collection with the <atom:category term="approval-action" .../> child element, and make a note of the web address in its href attribute.
- Find the entry representing the file that you want to take action on by getting a list of the entries awaiting approval. See Getting a list of community files that require action for more details. Make a note of the value of the <td:uuid> element for the entry representing the file.
- Create an Atom entry document that defines the action you want to perform. In the <snx:moderation action="xxx" /> element, choose one of the following options:
Approves the file entry and publishes it to the community.
Rejects the request for publication and does not publish the file.
Construct an <snx:in-ref-to> element that identifies the file that you want to take action on using the following syntax:
<snx:in-ref-to xmlns:snx="http://www.ibm.com/xmlns/prod/sn" rel="http://www.ibm.com/xmlns/prod/sn/report-item" ref-item-type="document" ref="<value_of_td:uuid>" > </snx:in-ref-to> <snx:moderation action="approve" />
where <value_of_td:uuid> is the value of the <td:uuid> element that you noted in Step 3.
For example, to approve a file, the Atom entry document might contain the following content:
<?xml version="1.0"?> <entry xmlns="http://www.w3.org/2005/Atom" xmlns:snx="http://www.ibm.com/xmlns/prod/sn"> <id>ignored</id> <title>ignored</title> <author> <name>ignored</name> <!-- taken from authenticated moderator user --> </author> <snx:in-ref-to xmlns:snx="http://www.ibm.com/xmlns/prod/sn" rel="http://www.ibm.com/xmlns/prod/sn/report-item" ref-item-type="document" ref="f0b0d8df-4b8d-4155-bf84-229af6a0eefc"> </snx:in-ref-to> <snx:moderation action="approve" /> <content>This content of this entry is not objectionable according to company guidelines.</content> </entry>
- Send a POST request to the web address that you noted in Step 2. Pass the Atom entry document that you created in the previous step as input on the request.
Table 1. Atom API request details
Method Resource URI Input representation POST Premoderation content approval status collection Value of the href attribute of the <collection> element that has the <atom:category term="approval-action" .../> child element having in the moderation service document. moderation action
InputProvide a moderation action Atom entry document. The content type of the Atom entry document must be application/atom+xml.
Returned HTTP headers
HTTP/1.1 204 No Content
Indicates that the entry was successfully moderated. If an error occurs, this header contains one of the error codes.
- HTTP/1.1 400 Bad Request
- HTTP/1.1 401 Unauthorized
- HTTP/1.1 403 Forbidden. Returned when the current user is authorized to the use the API, but cannot moderate the specified content.
- HTTP/1.1 404 Not Found. Indicates that the content is no longer available.
> POST files/basic/api/approval/actions/documents HTTP/1.1 > Authorization: Basic xxx > Host: enterprise.example.com > Accept: */* > Content-Type: application/atom+xml > Content-Length: 509
< HTTP/1.1 204 No Content
Parent topicWork with community files that are awaiting approval
Moderation action entry content