Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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

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

<photo></photo>
--8cfa2a52b1be413
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]
--8cfa2a52b1be413--

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

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

Does anyone know what would cause this?

share|improve this question
    
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

1 Answer 1

up vote 3 down vote accepted

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)

share|improve this answer
    
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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