How would I post an item to a contacts history via a post?

Skip to first unread message

John Wooten

Aug 22, 2019, 11:25:30 AM8/22/19
to Fat Free CRM Developers
I am attempting to have a button on a FFCRM page for a contact that causes an action to be performed on an external server.  I want to take the results of that action and post back to FFCRM contact page and add the results of that action to the history for that contact.  I don't see a way to do that right now.  I'd like to be able to have my external server send a post or GET to FFCRM/something?contact=xyz&action=history&msg=a_message and have that message added to the contacts history and saved.  

I'd appreciate any clues as to how to manage this.



Aug 23, 2019, 6:26:53 AM8/23/19
to Fat Free CRM Developers
This kind of thing is definitely possible if you are willing/able to code a little. do you know ruby/rails?

- for the button to send, that's going to require some editing of the views and controller code for contacts.

- for the post back to FFCRM, take a look at

you'll create an endpoint which loads a contact based on params then make whatever changes you need (add a message etc..) before saving it.

John Wooten

Aug 27, 2019, 11:55:49 AM8/27/19
to Fat Free CRM Developers
I do know some ruby/rails.  I have been attempting to post a comment to the contact using the following:

$('#msg').submit(function() {
// DO STUFF...
var displayDiv = document.getElementById('show_select');
var data = displayDiv.innerHTML;
= URI.parse("http://localhost:3000/comments");
Net::HTTP.start(, uri.port,
:use_ssl => uri.scheme == 'https',
:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|

= uri.request_uri
.basic_auth 'heather', 'heather'
.set_form_data( {
"comment[commentable_type]" => "Contact",
"comment[comment]" => "This is a test from curl in ruby",
"commit" => "Add Comment" } )

= http.request req # Net::HTTPResponse object

return true; // return false to cancel form action

Started POST "/comments" for at 2019-08-27 11:37:19 -0400


Processing by CommentsController#create as */*

Parameters: {"comment"=>{"commentable_type"=>"Contact", "comment"=>"This is a test from curl in ruby"}, "commit"=>"Add Comment"}

Can't verify CSRF token authenticity.

Completed 422 Unprocessable Entity in 0ms (ActiveRecord: 0.0ms)Enter code here...

I am using the demo data and heather/heather is the userid and password for heather whose contact I am trying to alter.

Any ideas about what to do here?


Aug 27, 2019, 7:07:14 PM8/27/19
to Fat Free CRM Developers
A couple of things: 

1. you might need to look at how comments are posted by the normal view action. at a glance you're missing some form data (id of contact?)


2. You can make your code work, but only by overriding (and disabling) some of the security features for that controller action. so I would think you'd be better to roll your own endpoint to handle this - see the extension I pointed you to previously.

if you are determined to make your code work as posted, you'd change the comments controller and add something like the following

protect_from_forgery :except => [:create]
def single_access_allowed?
      (action_name == "create" || action_name == " etc... if you need to whitelist other actions for http basic auth)
Reply all
Reply to author
0 new messages