+ Start a Discussion
DanielJimenezDanielJimenez 

Calling SalesForce API from Apex/VisualForce?

Does anyone have experience trying this? I'm building a page in force.com sites. Basically another tool will make an anonymous http POST call to this page to update a specific users chatter feed.

TIA,
Daniel
DanielJimenezDanielJimenez
AJAX won't work for an HTTP POST unfortunately.
cloudcodercloudcoder

Oh I see. So you want an external application to make an update to a users Chatter feed via HTTP post? Is that correct? If so, you could look at using the REST API, but you would have to write some javascript to dynamically update the page.

DanielJimenezDanielJimenez
I'd have to call the REST API from the Apex controller, correct? That is along the lines of what I was thinking.
cloudcodercloudcoder

Ok now I am a little confused. If you are already on the platform, I do not see the need to perform a REST call which would be effectively an outbound call, just to have access to local data.

 

Can you describe your use case more so I can fully understand what you are trying to achieve.

 

Thanks

 

DanielJimenezDanielJimenez
Well I'm running as a Guest user on Force.com sites. The guest user can not create FeedItems or perform any chatter interaction of any kind. So I need to make a call to the API logged in as a user with permission to create FeedItems. In short, we use WatchMouse.com for monitoring our application. WatchMouse has the ability to make an http post to send notifications. The parameters, etc are hard coded on WatchMouse's end. I'd like to build a simple page that can take that post and create a FeedItem on a users Chatter feed. Hope that makes sense! Daniel
DanielJimenezDanielJimenez
I gave up on getting the page running on force.com sites and just whipped up a quick locally hosted coldfusion page instead. Still like to figure it out, but I'll have to address it later.
Jan_SJan_S

Daniel, I am facing the same issue: I want to create a chatter FeedItem on a site as Guest user. Unfortunately, Guest user has no permission to write Chatter objects, neither can configure that in SalesForce (no settings for that).

 

Does anybody know how to impersonalize Guest user to run Apex code as System admin?

I also tried to store the chatter events in a custom sobject and then use a scheduled job (which runs as system admin) to insert FeedItems but I can schedule jobs just once an hour, which is not acceptable for me.

DanielJimenezDanielJimenez
Jan, glad to hear I'm not totally crazy! Let me know if you get anywhere!
DanielJimenezDanielJimenez
Also Jan, for what it's worth I was considering doing something along the same lines, using a trigger rather than a scheduled task. I decided that was too "hacky" of a solution, and ending up building what I needed using another platform.
Jan_SJan_S

Hi, I have already tried triggers too :) The problem is that if you make a change on an SObject as user Guest then the trigger is called under the same user, so I get the same permission error as before.

Matt R.ax1440Matt R.ax1440

I am having this same problem...  Did anyone come up with another workaround?   The custom SObject approach seems the only way to go, but there has to be a better way.