• ycheneval
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies

Hello,

 

Trying to post a file using the REST API gives an error:

<?xml version="1.0" encoding="UTF-8"?><Errors><Error><errorCode>MISSING_ARGUMENT</errorCode><message>No attachment found and body is empty. Provide a non-empty &apos;text&apos; parameter, or a rich input including non-empty message segments. If providing rich JSON/XML input in REST, make sure to include Content-Type header. In multipart REST, include the Content-Type in the part.</message></Error></Errors>

 

The content of my request is the one taken from the documentation [full request on the bottom of this post]:

http://www.salesforce.com/us/developer/docs/chatterapi/Content/intro_input.htm#cc_upload_binary_files

 

I tried the json, older version of the API (V27.0), got the same messages. Since I had this error in my implementation, I tried using a Chrome extension called ‘Advanced REST Client’ and got the same message so obviously I'm doing something wrong or the request has a problem.

 

Now, the id I'm using here is from a custom object that has Feeds. If I'm posting a standard Text post/comment to it , all is working correctly, but file uploads are not working. Since I'm taking the exact documentation sample, it seems weird.

 

Any thoughts ?

 

--- Full request below

 

POST /services/data/v27.0/chatter/feeds/record/a0tg00000008sFFAAY/feed-items HTTP/1.1
Host: weforum--r4dev.cs17.my.salesforce.com
Connection: keep-alive
Content-Length: 951
Cache-Control: no-cache
Pragma: no-cache
Accept: application/xml
Origin: chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36
Authorization: OAuth 00Dg00000005EHf!ARIAQJry9BazRT_G1jw_nQBm_kN990VDYK87S_xsJ6MS3dTb5UNnlJVcJF72psrBQ8H1LtZPlSLCkmlZuf2GxGBNYoia4ECS
Content-Type: multipart/form-data, boundary=0HWq8x4y4DSQ4fqjXt6MinVMyqbf1r
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8

--0HWq8x4y4DSQ4fqjXt6MinVMyqbf1r
Content-Disposition: form-data; name="xml"
Content-Type: application/xml; charset=UTF-8

<feedItem>
   <body>
      <messageSegments>
         <segment>
            <text>High priority content </text>
            <type>Text</type>
         </segment>
         <segment>
             <tag>important</tag>
            <type>Hashtag</type>
         </segment>
         <segment>
            <text>Please review this as soon as possible</text>
            <type>Text</type>
         </segment>
      </messageSegments>
   </body>
   <attachment attachmentType="NewFile">
      <description>Quarterly review 2012 Q1</description>
      <title>2012_q1</title>
   </attachment>
</feedItem>

--0HWq8x4y4DSQ4fqjXt6MinVMyqbf1r
Content-Disposition: form-data; name="feedItemFileUpload"; filename="foo"
Content-Type: application/octet-stream; charset=ISO-8859-1

This is the content of the file.
--0HWq8x4y4DSQ4fqjXt6MinVMyqbf1r--
 

 

 

Hello,

 

Trying to post a file using the REST API gives an error:

<?xml version="1.0" encoding="UTF-8"?><Errors><Error><errorCode>MISSING_ARGUMENT</errorCode><message>No attachment found and body is empty. Provide a non-empty &apos;text&apos; parameter, or a rich input including non-empty message segments. If providing rich JSON/XML input in REST, make sure to include Content-Type header. In multipart REST, include the Content-Type in the part.</message></Error></Errors>

 

The content of my request is the one taken from the documentation [full request on the bottom of this post]:

http://www.salesforce.com/us/developer/docs/chatterapi/Content/intro_input.htm#cc_upload_binary_files

 

I tried the json, older version of the API (V27.0), got the same messages. Since I had this error in my implementation, I tried using a Chrome extension called ‘Advanced REST Client’ and got the same message so obviously I'm doing something wrong or the request has a problem.

 

Now, the id I'm using here is from a custom object that has Feeds. If I'm posting a standard Text post/comment to it , all is working correctly, but file uploads are not working. Since I'm taking the exact documentation sample, it seems weird.

 

Any thoughts ?

 

--- Full request below

 

POST /services/data/v27.0/chatter/feeds/record/a0tg00000008sFFAAY/feed-items HTTP/1.1
Host: weforum--r4dev.cs17.my.salesforce.com
Connection: keep-alive
Content-Length: 951
Cache-Control: no-cache
Pragma: no-cache
Accept: application/xml
Origin: chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36
Authorization: OAuth 00Dg00000005EHf!ARIAQJry9BazRT_G1jw_nQBm_kN990VDYK87S_xsJ6MS3dTb5UNnlJVcJF72psrBQ8H1LtZPlSLCkmlZuf2GxGBNYoia4ECS
Content-Type: multipart/form-data, boundary=0HWq8x4y4DSQ4fqjXt6MinVMyqbf1r
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8

--0HWq8x4y4DSQ4fqjXt6MinVMyqbf1r
Content-Disposition: form-data; name="xml"
Content-Type: application/xml; charset=UTF-8

<feedItem>
   <body>
      <messageSegments>
         <segment>
            <text>High priority content </text>
            <type>Text</type>
         </segment>
         <segment>
             <tag>important</tag>
            <type>Hashtag</type>
         </segment>
         <segment>
            <text>Please review this as soon as possible</text>
            <type>Text</type>
         </segment>
      </messageSegments>
   </body>
   <attachment attachmentType="NewFile">
      <description>Quarterly review 2012 Q1</description>
      <title>2012_q1</title>
   </attachment>
</feedItem>

--0HWq8x4y4DSQ4fqjXt6MinVMyqbf1r
Content-Disposition: form-data; name="feedItemFileUpload"; filename="foo"
Content-Type: application/octet-stream; charset=ISO-8859-1

This is the content of the file.
--0HWq8x4y4DSQ4fqjXt6MinVMyqbf1r--