function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Diego RomeraDiego Romera 

Chatter API - Attach new file in feed and get a bad request (400 error)

Hi there,

 

My web is connected with Chatter API to send feed to user's wall. I would like to attach an image as well with that feed but I've been getting a bad request, a 400 every time I try to upload an image. I'm really depressed because I don't know what's happening even when headers and request are the same I think. To test it I checked the request in the web site http://requestb.in/ which let you check every single request in order to see the headers, so text below is request I have been doing. 

 

The API url I've been pointing is https://eu2.salesforce.com/services/data/v29.0/chatter/feeds/user-profile/me/feed-items

 

http://requestb.in
POST /1eiyqrn1
 multipart/form-data; boundary=AIhbE7z31385469858821
 21.77 kB
23s ago  
From 83.61.20.90
FORM/POST PARAMETERSNone
HEADERS

Content-Type: multipart/form-data; boundary=AIhbE7z31385469858821

Accept: application/json

Authorization: OAuth xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Host: requestb.in

User-Agent: Mozilla/5.0 (X11; Linux i686 (x86_64)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.114 Safari/537.36

Content-Length: 22288

Connection: close

RAW BODY
--AIhbE7z31385469858821Content-Disposition: form-data; name="json"Content-Type: application/json; charset=UTF-8{"body":{"messageSegments":[{"type":"Text","text":"fdsgds"},{"type":"Link","url":"http://localhost:8080/#/explore?a=fdsgds"}]},"attachment":{"attachmentType":"New File","description":"description","title":"fdsgds"}}--AIhbE7z31385469858821Content-Disposition: form-data; name="feedItemFileUpload"; filename="ideasEmpty.jpg"Content-Type: application/octet-stream; charset=ISO-8859-1ÿØÿáExifII*ÿìDucky<ÿá-http://ns.adobe.com/xap/1.0/<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?> <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.3-c011 66.145661, 2012/02/06-14:56:27        "> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/" xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/" xmlns:stRef="http://ns.adobe.com/xap/1.0/sType/ResourceRef#" xmp:CreatorTool="Adobe Photoshop CS6 (Macintosh)" xmpMM:InstanceID="xmp.iid:FDD0A1F3A36111E2B341B338BCE5F8D0" xmpMM:DocumentID="xmp.did:FDD0A1F4A36111E2B341B338BCE5F8D0"> <xmpMM:DerivedFrom stRef:instanceID="xmp.iid:FDD0A1F1A36111E2B341B338BCE5F8D0" stRef:documentID="xmp.did:FDD0A1F2A36111E2B341B338BCE5F8D0"/> </rdf:Description> </rdf:RDF> </x:xmpmeta> <?xpacket end="r"?>ÿîAdobedÀÿÛ„		

ÿÀÿxÿħ!1AQaq"2�‘B¡#ÁRbr±Ñá‚’¢3$ðC4²Sc%!1A"Q2ðaq�ÁB‘¡±Rr#Ñáñ3ÿÚ?ꔀ@ €(Bdn*¹¾dkPJÁ‚	9Ñ W¾Üvûsqu¥¸ÀÍ;Û?Ôâ[]Û]BË‹iY=¼‚±ÏƒØáZ`æ’

 Thanks in advance.

 

Diego

alouie_sfdcalouie_sfdc
I can't tell because of how the raw body got formatted, but is there an empty line after this?

Content-Type: application/octet-stream; charset=ISO-8859-1

Also, was there an error message returned along with the HTTP 400?
Diego RomeraDiego Romera

Hi alouie!

 

Firstly apologies for the delay. I've been struggling with this issue eventually I managed to do it. I changed the libraries so that I use jersey as a client. Everything works right now.

 

Thank you so much

 

Diego