Newer Version Available

This content describes an older version of this product. View Latest

Feed Elements, Batch Post

Post a batch of up to 500 feed elements.
Resource
1/chatter/feed-elements/batch
1/connect/communities/communityId/chatter/feed-elements/batch
Available version
32.0
Requires Chatter
Yes
HTTP methods
POST, HEAD
Request body for POST
Batch Collection Input
The rich input for this batch collection is a Feed Item Input
Response body for POST
Batch Results
The Batch Results response body contains Feed Item response bodies corresponding to each of the request bodies. The Feed Item response bodies are returned in the same order as the request bodies.
The request returns an HTTP 200 status code unless an error occurs that affects the entire request (such as a parsing failure). If an individual request body causes an error, the Batch Results Item statusCode property contains the appropriate HTTP status code.
Post a batch of feed elements
This example uses the /chatter/feed-elements/batch resource to post a batch of feed elements. This example uses cURL.
1curl -H "X-PrettyPrint: 1" -F 'json={"inputs":[{"richInput":{"subjectId":"me","body":{"messageSegments":[{"type":"Text","text":"Post Number 1"}]},"feedElementType":"FeedItem"}},{"richInput":{"subjectId":"me","body":{"messageSegments":[{"type":"Text","text":"Post Number 2"}]},"feedElementType":"FeedItem"}}]};type=application/json' -X POST https://instance_name/services/data/v53.0/chatter/feed-elements/batch -H 'Authorization: OAuth 00DD00000007HoR!...' --insecure
Here’s the same example showing just the request body:
1{
2  "inputs": [
3    {
4      "richInput": {
5        "subjectId": "me",
6        "body": {
7          "messageSegments": [
8            {
9              "type": "Text",
10              "text": "Post Number 1"
11            }
12          ]
13        },
14        "feedElementType": "FeedItem"
15      }
16    },
17    {
18      "richInput": {
19        "subjectId": "me",
20        "body": {
21          "messageSegments": [
22            {
23              "type": "Text",
24              "text": "Post Number 2"
25            }
26          ]
27        },
28        "feedElementType": "FeedItem"
29      }
30    }
31  ]
32}

Post a batch of feed elements with binary files (version 35.0 and earlier)

This example uses the /chatter/feed-elements/batch resource to post a batch of feed elements, upload two binary files, and attach them to the feed elements in the batch. Include the information about the binary parts in the request body. This example uses cURL.
1curl -H "X-PrettyPrint: 1" -F 'json={"inputs":[{"binaryPartNames":["bin1"], "richInput":{"subjectId":"me","body":{
2"messageSegments":[{"type":"Text","text":"Please accept this receipt"}]},"capabilities": {"content" : {"description": "Receipt for expenses", "title":"receipt.pdf"}},"feedElementType":"FeedItem"}},
3{"binaryPartNames":["bin2"],"richInput":{"subjectId":"me","body":{"messageSegments":[{"type":"Text","text":"Post Number 2"}]},
4"capabilities": {"content" : {"description": "Receipt for expenses", "title":"receipt2.pdf"}},"feedElementType":"FeedItem"}}]};type=application/json' 
5-F "bin1=@/Users/jsmith/Desktop/receipt.pdf;type=application/octet-stream" -F "bin2=@/Users/jsmith/Desktop/receipt2.pdf;type=application/octet-stream" 
6-X POST https://instance_name/services/data/v35.0/chatter/feed-elements/batch 
7-H 'Authorization: OAuth 00DD00000007HoR44QATPNzhzYEJBfU' --insecure
Here is the same example formatted to show the request body parts.
1POST /services/data/v35.0/chatter/feed-elements/batch HTTP/1.1
2Authorization: OAuth 00DRR0000000N0g!...
3User-Agent: Jakarta Commons-HttpClient/3.0.1
4Host: instance_name
5Content-Length: 845
6Content-Type: multipart/form-data; boundary=a7V4kRcFA8E79pivMuV2tukQ85cmNKeoEgJgq
7Accept: application/json
8
9--a7V4kRcFA8E79pivMuV2tukQ85cmNKeoEgJgq
10Content-Disposition: form-data; name="json"
11Content-Type: application/json; charset=UTF-8
12
13{
14  "inputs": [
15    {
16      "binaryPartNames": [
17        "bin1"
18      ],
19      "richInput": {
20        "subjectId": "me",
21        "body": {
22          "messageSegments": [
23            {
24              "type": "Text",
25              "text": "Please accept this receipt"
26            }
27          ]
28        },
29        "capabilities": {
30          "content": {
31            "description": "Receipt for expenses",
32            "title": "receipt.pdf"
33          }
34        },
35        "feedElementType": "FeedItem"
36      }
37    },
38    {
39      "binaryPartNames": [
40        "bin2"
41      ],
42      "richInput": {
43        "subjectId": "me",
44        "body": {
45          "messageSegments": [
46            {
47              "type": "Text",
48              "text": "Post Number 2"
49            }
50          ]
51        },
52        "capabilities": {
53          "content": {
54            "description": "Receipt for expenses",
55            "title": "receipt2.pdf"
56          }
57        },
58        "feedElementType": "FeedItem"
59      }
60    }
61  ]
62}
63
64--a7V4kRcFA8E79pivMuV2tukQ85cmNKeoEgJgq
65Content-Disposition: form-data; name="bin1"; filename="receipt.pdf"
66Content-Type: application/octet-stream; charset=ISO-8859-1
67
68...contents of receipt.pdf...
69
70
71--a7V4kRcFA8E79pivMuV2tukQ85cmNKeoEgJgq
72Content-Disposition: form-data; name="bin2"; filename="receipt2.pdf"
73Content-Type: application/octet-stream; charset=ISO-8859-1
74
75...contents of receipt2.pdf...
76
77--a7V4kRcFA8E79pivMuV2tukQ85cmNKeoEgJgq--

The binary part names in the binaryPartNames properties must match the binary part names in the name properties of the binary request parts.

Note