Skip to main content

Hi Experts,

I'm currently making a REST call to a third-party system using the IFS Custom Event action type "REST Call" to create a new customer. The payload is simple: 

{ "CustomerId": "&NEW:CUSTOMER_ID", "Name": "&NEW:NAME" }

This works fine for sending data. However, I need to capture the response from this call—specifically when the customer creation fails, it should log that error into a custom table/custom LU in IFS. Although I can view the response in the Application Messages, I think querying those messages and updating the custom Logical Unit (LU) might not be reliable when multiple requests are being processed concurrently.

I'm considering using the PLSQL_REST_SENDER_API in the event action (with type ‘Execute Online SQL’) to make the call synchronously, so I can capture the response directly and log any errors immediately into the custom LU.

Could anyone provide guidance or an example of how to use PLSQL_REST_SENDER_API for a synchronous REST call and handle the response?

Thanks in advance for your help!

Further to add on to the question. 

Can we use PLSQL_REST_SENDER_API.Call_Rest_EndPoint_Empty_Body or any other suggestions with your past experiences would be appreciated. 


@dsj  Any inputs on this please?  :) 


Hi ​@Rajitha Herath,

 

Here’s an sample for plsql_rest_sender_API.Call_Rest_EndPoint_Json. Call signature is similar for Call_Rest_EndPoint_Empty_Body sa well 🙂 Only the difference is there’s no need of a paylod (json_)

  plsql_rest_sender_API.Call_Rest_EndPoint_Json( rest_service_ => 'XXX_Shipment',
                                                 json_ => json_clob_,
                                                 message_id_ => message_id_,
                                                 url_params_ => url_,
                                                 sender_ => 'XXX_INTEGRATION',
                                                 callback_func_ =>'XXX_Util_API.REST_Callback',
                                                 http_method_ => 'POST',
                                                 http_req_headers_ =>'Content-Type:application/json',
                                                 accepted_res_codes_  => '201',
                                                 key_ref_ => shipment_id_);

Response Handling:

This example uses the keyref which was sent with the request to modify the corresponding record. You can also define response handling without using the keyref. Check the documentation for callback method signature format.

Configure the REST Transport Connector - Technical Documentation For IFS Cloud

PROCEDURE REST_Callback (xml_ CLOB, app_msg_id_ VARCHAR2, key_ref_ VARCHAR2)
IS
  track_id_    VARCHAR2(2000);
  --external_id_ VARCHAR2(2000);
  attr_        VARCHAR2(2000);
  info_        VARCHAR2(2000);
  objid_       VARCHAR2(2000);
  objversion_  VARCHAR2(2000);
  shipment_id_ NUMBER;
BEGIN
  shipment_id_ := key_ref_;
  Shipment_API.Exist(shipment_id_);

  track_id_ := JSON_VALUE(xml_, '$.ShpNo');
  Client_SYS.Clear_Attr(attr_);
  Client_SYS.Add_To_Attr('C_EXTERNAL_ID', track_id_, attr_);
  Shipment_API.Modify(attr_, shipment_id_);  
END;

 

One thing, Response callback works only for the application messages which are successfully executed (State = Finished). I’m not sure when you say handling failed messages, does it mean the application message fails or it set to finish but the response contains some information about the failure.

There’s a parameter failed_callback_fun_ in the plsql_rest_sender_API procedures which looks like for handling failed requests but unfortunately I haven’t used it :|

 

Hope it helps!
Damith


@dsj Thank you for the reply Damith. It helps!

Sorry, actually I meant both the scenarios. Application message being failed (eg - 400, 401 errors) and also scenarios where the application message is in Finished state - but response could be like “Part does not exist” or something like that, so that I should be able to capture both the scenarios and log it in a custom LU. Appreciate if you have any further input for that scenario, of course your 1st reply helped me to clarify some points, but just to highlight here that we are just going to go with Configurations and no build place access for code level changes :) 


 

@dsj I just tried the setup with a Postman Mock server. I have a response defined there. When the event is triggered from IFS, it is successfully received on the Postman end, and in return I can also see the response in the Application Messages. Now, I need to capture that response into a custom logical unit (a custom log table) without querying it from the Application Messages.

My challenge is that I do not have access to the code level,  so failed_callback_fun_ can not be implemented thereso I'm wondering if what I'm trying to do is feasible through configuration alone. Or is there any other way to capture the response ? Appreciate any suggestions or inputs. Thanks

 


Hi ​@Rajitha Herath 

 

If you don’t have access to code level, a workflow would be a better alternate for your requirement since then you can handle the response and update a custom LU inside the workflow. Have you already considered that path? :)

 

/Damith


@dsj Hi Damith, Sounds great! No I haven’t tried that path. I think I have seen a blog post by you about REST calls and Workflows, can you point me there if that suits this scenario or any example or guidance would be appreciated! :) 


@dsj Hi Damith, Sounds great! No I haven’t tried that path. I think I have seen a blog post by you about REST calls and Workflows, can you point me there if that suits this scenario or any example or guidance would be appreciated! :) 

 

Hi ​@Rajitha Herath 

 

You might be referring to this :D 

Send Data to a REST API using IFS Workflow – DSJ's Blog

It explains how to send data to a rest endpoint and process the response. Inserting data to the custom LU can be done using the IFS API call to the created projection for the LU.

 

Cheers!

Damith


@dsj Hi Damith, Thanks a lot! That example really helped and I was able to send the data to the Postman mock server and process the response correctly. The IFS API call to the LU projection worked like a charm. Marking it as the Best Answer! :) 


Reply