Skip to main content
Question

reliably get response of a RESTful POST request

  • November 4, 2024
  • 2 replies
  • 123 views

Forum|alt.badge.img+10
  • Hero (Customer)
  • 72 replies

Hi,

We have a requirement to invoke a REST API POST request to an external system under certain circumstances, and in some cases there may be many messages to send within a short period.  I’m therefore sending them as an asynch call using Plsql_Rest_Sender_API.Call_Rest_EndPoint_Json with both a callback and error function defined:

   Plsql_Rest_Sender_API.Call_Rest_EndPoint_Json( 

            rest_service_,  

            xml_,

            url_params_ => NULL,  

            callback_func_ => XXX_API.Ok_Callback',  

            http_method_ => 'POST',

            http_req_headers_ => 'X-Authorization: Bearer ' || token_,

            key_ref_   => key_ref_,

            failed_callback_fun_ => 'XXX_API.Failed_Callback',  

            accepted_res_codes_  => '200');  
 
 

The successful callback function is defined as:

PROCEDURE Ok_Callback (xml_clob_ CLOB, app_msg_id_ VARCHAR2, key_ref_ VARCHAR2)

This is all working fine but I’m having problems reliably getting the body of the successful response in the callback function.  I’ve made use of the information in 

https://community.ifs.com/framework-experience-infrastructure-cloud-integration-dev-tools-50/how-to-capture-the-response-of-a-restful-post-request-37529

 

and I’ve found that the response could be in seq_no 2 or 3.  Once the application message shows as finished I can see the response in the database in the MESSAGE_VALUE field of the MESSAGE_BODY table using

select application_message_id, seq_no, message_text, utl_raw.cast_to_varchar2(dbms_lob.substr(message_value,2000,1)) FROM MESSAGE_BODY

However, if I use this in the callback function it doesn’t always get the responses.  It works if the response_body is in seq_no 2, but when the response_body is in seq_no 3 the callback function only finds the entry for seq_no 1.

Is there something I need to do or something I’ve missed which will ensure that the callback function will reliably get the response body?

Any suggestions much appreciated!

Thanks,

mmck

2 replies

PhillBronson
Hero (Customer)
Forum|alt.badge.img+11
  • Hero (Customer)
  • 161 replies
  • June 16, 2025

@MMcK did you ever get the callback to work reliably?

If so, what was the solution?


Forum|alt.badge.img+10
  • Author
  • Hero (Customer)
  • 72 replies
  • June 16, 2025

Hi Phil

We did.  The way we found that worked most reliably was to do a deferred call if we didn’t get a response in our callback function.  This checked later and literally worked through each sequence numbered record to get the response text.  We found examples where there was 3 entries but the response could be in seq_no 2, so it’s not necessarily in the highest numbered record.  This has been working well for us for over a year now, it seems the slight delay from invoking a separate background job was sufficient to get all the response data.

In case it helps… it took me a while to realise that the normal callback function will be called as well as the failed call back.  I had sort-of assumed the normal callback meant success.  The failed call back function is only called once all the standard retries have failed. 

Good luck, let me know if you need any further info.

MMcK


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings