Within the Contacts grid on the Customer page, I added a Custom Menu option that allows the user to highlight a Contact, RMB click, and select “Push to Salesforce”. This calls an externally hosted REST API that gets the details, does a bunch of backend validation and such, and then pushes the contact to our CRM. It works great using the code below:
DECLARE
person_id_ VARCHAR2(50) := &PERSON_ID;
url_params_ plsqlap_record_api.type_record_;
BEGIN
url_params_ := Plsqlap_Record_API.New_Record('URL_PARAMETERS');
Plsqlap_Record_API.Set_Value(url_params_ ,'personid', person_id_, caseSensitive_ => TRUE);
Plsql_Rest_Sender_API.Call_Rest_EndPoint_Empty_Body(rest_service_ =>'SEND_CONTACT_TO_SF',
url_params_ => url_params_ ,
http_method_ => 'GET',
sender_ => 'CONNECT',
receiver_ => 'INTEGRATION_API'
);
END;
It has worked flawlessly for about 8 months now, but I’ve been tasked with automating it so the extra RMB click is no longer necessary. So, I created a custom event that automatically calls the API when certain fields are updated on the contact, and it fires as expected calling the assigned action.
I tried wiring up the built-in REST API Custom Event Action, but it never worked, and after reading lots of posts where others gave up and found success using the Execute Online SQL action instead, I also went that route. I basically copied the exact same SQL code from my Custom Menu event with one change - I replaced the person_id_ variable value with the appropriate substitution field, but otherwise, it’s exactly the same. The modified code is below.
DECLARE
person_id_ VARCHAR2(50) := '&NEW:PERSON_ID';
url_params_ plsqlap_record_api.type_record_;
BEGIN
url_params_ := Plsqlap_Record_API.New_Record('URL_PARAMETERS');
Plsqlap_Record_API.Set_Value(url_params_ ,'personid', person_id_, caseSensitive_ => TRUE);
Plsql_Rest_Sender_API.Call_Rest_EndPoint_Empty_Body(rest_service_ =>'SEND_CONTACT_TO_SF',
url_params_ => url_params_ ,
http_method_ => 'GET',
sender_ => 'CONNECT',
receiver_ => 'INTEGRATION_API'
);
END;
I’ve confirmed that the action is being triggered by inserting this into the code and seeing the popup on the screen.error_sys.appl_general('CustomerInfoContact','Event Action Executing for PersonID: :P1', person_id_);
But the call never reaches the API. The event is added to the OUT1 queue, and sender attempts to send it, but the Application Message in the queue always reads “Failed: Bad Request(400)”. It’s never even reaching the API endpoint. What am I doing wrong?