I'm using C#.Net to (upload) POST a new User Photo to Salesforce.

Using Fiddler I'm able to monitor the HTTP activity to and from my computer.

Here's the raw data I'm sending in the POST (with parts in brackets excluded):

POST https://cs7.salesforce.com/services/data/v26.0/chatter/users/[my User Id]/photo HTTP/1.1
Authorization: OAuth [my Salesforce Session Id]
Content-Type: multipart/form-data; boundary=8cfa2a52b1be413
Host: cs7.salesforce.com
Content-Length: 15054
Expect: 100-continue

Content-Disposition: form-data; name="xml"
Content-Type: application/xml; charset=UTF-8
Content-Transfer-Encoding: 8bit

Content-Disposition: form-data; name="fileUpload"
Content-Type: application/octet-stream; charset=ISO-8859-1
Content-Transfer-Encoding: binary

[binary data for a jpg file]

However, I'm receiving this error back from Salesforce:

HTTP/1.1 500 Server Error
Date: Fri, 07 Dec 2012 21:17:58 GMT
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked

[{"message":"An unexpected error occurred. Please include this ErrorId if you contact support: 160445444-13550 (94877017)","errorCode":"UNKNOWN_EXCEPTION"}]

Does anyone know what would cause this?

  • I just sent a note to the internal team regarding the error, if you file a case please post the case number here. – Ryan Guest Dec 10 '12 at 2:17

Thoughts: Looking at the documentation you appear to be doing the correct thing here, and as per below this is an unexpected exception from the platform. So other than following the support route (which would not harm), we are on our own. So its time to experiment, apologies if you have tried some of these, but maybe some will spark another avenue...

  • Have you tried it with the /user/me/photo?
  • Have you tried it with a different image format?
  • Have you confirmed the content of the tag is valid?
  • What happens if you don't send the image data? Does it give another error that is meaningful? Perhaps relates to some other issue the unhandled one is masking?
  • Does it work if you do it via the UI?
  • Can you find another app that does this and use Fiddler to review its HTTP messages?
  • Have you tried it in a Developer Org as apposed to your Sandbox?

Salesforce Internal Error Codes: What your receiving is an unhandled / unexpected exception from Salesforce. Only Salesforce support can decode internally the error message behind it and hopefully give you a clue as to what might be going wrong to cause this. As its unhandled / unexpected its likely you've found a bug of some kind. However its also likely the correct passing of information can be found once more is known, as I suspect this a issue in the API's internal validation code. As the message says I would contact Salesforce support and provide them with the codes.

Please include this ErrorId if you contact support: 160445444-13550 (94877017)

  • Excellent answer; thanks! I'm working through the list of suggestions you mentioned. – Matt K Dec 10 '12 at 15:31
  • After many trial & error attempts at getting this to work, I realized I needed to use JSON instead of XML in the first part of the POST (after the first boundary: --8cfa2a52b1be413). For a full example of what worked, see this answer. – Matt K Dec 12 '12 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.