I am using the Ruby Gem "databascdotcom" to integrate Salesforce in a Rails app and all works fine.
But getting following error on first call to salesforce:
The requested resource does not exist
If I refresh (Ctrl + F5) the page again, it works fine without any error.
Here is my code:
def SalesForceFeed
@oppID = params[:oppid]
client = Databasedotcom::Client.new client.client_id #=> foo client.client_secret #=> bar
client.authenticate :username => "foo@bar.com", :password => "ThePasswordTheSecurityToken" #=> "the-oauth-token"
client.materialize("Opportunity")
begin
@client=SalesForce::Connection.new.client
@opp = Opportunity.find_by_Id(@oppID)
rescue Exception=>e
if(e.message == "The requested resource does not exist")
return redirect_to :action => 'SalesForceFeed', :oppid => @oppID
end
end
On the first call to "SalesForceFeed" it returned the error "The requested resource does not exist", so I added an excepton check and called "SalesForceFeed" again, but I know this is not the right way.
Please suggest me a better way to fix this. Thanks.
Finally i got the issue. There was a wrong object added in materialize. I removed that and it's fixed.