4

I'm trying to upload an image file to Facebook from Salesforce and current this is my codes and it is not working can anyone help me fix it?

Please Note that my Image file is inside the Accounts Notes & Attachments


I tested the string that I use for salesforcephoto and it Uploaded something onto Facebook using the Facebook Graph API explorer Uploaded using Facebook Graph API Explorer

Save Session for the Facebook Graph API Explorer Click Here


The String I use for salesforcephoto

String salesforcephoto = 'https://c.ap4.content.force.com/servlet/servlet.ImageServer?file='+lstRelatedAttach[0].Id+'&oid=' + orgid ;

The Codes are Codes


Debug Log Errors

Debug Log Errors


Redirecting to login page

Currently this my link I'm using for my testing and it will redirect me to the login page instead of showing the image.

https://c.ap4.content.force.com/servlet/servlet.FileDownload?file=00P6F00001G81jz&oid=00D6F000001vFKh


I have tested this other link but it will give me an error message

https://c.ap4.content.force.com/servlet/servlet.ImageServer?id=00P6F00001G81jz&oid=00D6F000001vFKh

enter image description here

  • 1
    Please explain what you are trying to do? – Saroj Bera Mar 31 '17 at 9:46
  • I'm trying to upload a photo onto Facebook from Salesforce using the photo's URL that is from Salesforce – Luke Au Mar 31 '17 at 9:48
1

I need to add the file to the a document folder before I can access the url at other locations

| improve this answer | |
0

The first thing that stands out to me is that you have that url for the salesforce document added directly as a query string parameter, when you should url encode it first:

...'/Photos?url=' + EncodingUtil.urlEncode(salesforcephoto, 'UTF-8');

Also the format of the salesforce document url should be something like:

https://c.ap4.content.force.com/servlet/servlet.ImageServer?id=<id>&oid=<oid>&lastMod=1490673363000

Where <id> is the id of the document, and <oid> is the id of you org. I believe the lastMod param is optional.

That other url with the resource at /servlet/servlet.FileDownload?file= is for the same image, but requires login.

| improve this answer | |

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.