• Vikas Malhotra.ax1630
  • NEWBIE
  • 0 Points
  • Member since 2013

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

Hi everyone,

 

I have a big problem that I cannot get my head around:

 

We created a REST API that returns an object with a rich text field in it. It displays beautifully without any trouble IF you are logged in to Salesforce.com directly. If however you are only using OAUTH to authenticate it cannot access the images of this rich text field.

 

Here an example JSON for a rich text field as we get it in html format:

 

...

"article" : "<p class=\"MsoNormal\"></p>\n<p class=\"MsoNormal\" style=\"text-align: center; \"><img src=\"https://c.eu2.content.force.com/servlet/rtaImage?eid=a06b0000003Xvrq&amp;feoid=00Nb0000000yu5o&amp;refid=0EMb0000000Kyui\" alt=\"User-added image\"></img></p>"

...

 

How can it be that I can get all text and formatting ok but not access the image via OAUTH?

 

Any help would be greatly appreciated!

 

Florian

So I've been going around and around about this for a while now and nothing in the documentation seems to be accurate.  Hopefully I will supply enough detail that this matter can be solved.  I need to be able to retrieve any file that a user posts to chatter regardless of the size of the file.

 

I have a file which I posted to chatter via the web.

https://na9.salesforce.com/069E00000002wvT

When I look at the page it is listed under Chatter>>Files>>(FileName)

 

When I query for the file it only appears in Commencement

{"attributes":

{"type":"ContentDocument","url":"/services/data/v24.0/sobjects/ContentDocument/069E00000002wvTIAQ"},

"Id":"069E00000002wvTIAQ",

"CreatedById":"005E0000001zY1VIAU",

"CreatedDate":"2012-09-05T19:46:38.000+0000",

"LastModifiedById":"005E0000001zY1VIAU",

"LastModifiedDate":"2012-09-05T19:46:38.000+0000",

"IsArchived":false,

"ArchivedById":null,

"ArchivedDate":null,

"IsDeleted":false,

"OwnerId":"005E0000001zY1VIAU",

"SystemModstamp":"2012-09-05T19:46:39.000+0000",

"Title":"Trystan24hoursOld",

"PublishStatus":"P",

"LatestPublishedVersionId":"068E00000003GMnIAM"}

 

*The object above looks nothing like the ContentDocument Model provided here:

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_contentdocument.htm#sforce_api_objects_contentdocument

 

So, I have an OAuth token authorizing my Remote Access App. I'm using the REST API.  How do I download the file?  What I'm really trying to avoid here is screen scraping or other halfass methods like storing my clients' username and password.

 

I was following this tutoiral:

http://danlb.blogspot.com/2012/06/salesforce-rest-api-read-file.html

but it obviously doesn't work, because it uses the "Document" sObject and the file I have doesn't appear there:

[{"message":"The requested resource does not exist","errorCode":"NOT_FOUND"}]

 

 

What I am hoping for:

Some call that will return a https://direct/link/to/the/file/i/want/to/download.jpg where I can pass "Authorization OAuth: <access_token>" in the headers and download the actual file.

 

What I will settle for:

Any programmatic way of retrieving the file that does not involve the customer having to divulge their username and password to me in order screen scrape SF to login and get to the file.