Page to handle post request
Question

Hi All,

We are trying to accept post request from third party application into our Outsystems application. Requirement is to display the post attributes in Outsystems application page.

Is it possible to develop a page in Outsystems to handle post request from the third party site?

We have also tried exposing post rest service to accept post request, however there is no provision in Outsystems to redirect the captured post attributes to application page from server action.


Regards,

Varun

Hi Sandeep,

You can avoid to use javascript timer with slight change.

Write REST service accepting POST in Outsystems and use this Outsystems service url for redirection from external(.net) application. As soon as post request is received from external(.net) application, fetch post paramaters and set it in request parameter of destination page in the location header.

courtesy: Amal Raj (MVP)

Thanks,

Varun

Hi Varun,

thanks for the response we tried the same from our end but redirection is happening properly, I'll attach OAP for your reference , Please tell us if any modifications required .

Note: I didn't used GetRequest method because I don't require the data coming from the other end, It's fine if I can handle the POST request and redirection happens properly.

With Regards,

Sandeep.

TestRedirection.oap

mvp_badge
MVP

Hi Varun,

Yes that is possible. In traditional Web you would create a screen with input parameters attached to an entry point. In the preperation action you do the processing and then at the end redirect to a screen.

Like for example:


In Reactive Web you can use a similar pattern but then instead of the Preperation put your logic in the OnInitialize event handler:

Regards,

Daniel

Hi Daniel,

Thanks for the quick reply.

This may work with HTTP GET, but it is somehow not working as expected with POST request.Am i missing some essential trick here. What i need to write into initialize ? Do i need to create as many inputs as attributes in post request then only it will accept post? 

I am getting below error on redirection. Hence it very misleading.

mvp_badge
MVP

Hi Varun,

You'r right, I didn't read carefully your post.

Thinking about your initial approach:

We have also tried exposing post rest service to accept post request, however there is no provision in Outsystems to redirect the captured post attributes to application page from server action.

You could try this (I didn't have time to try myself, sorry)

  1.  In the POST method, raise an exception, call the exception "PostCallBack".
  2. Use the exception message to store a serialized string of the POST parameters
  3. In the Common/OnException handler, add an exception handler for "PostCallBack"
  4. In the exception handler deserialize the exception message back to parameter values
  5. Set the destination screen with the parameters.

Regards,

Daniel

Hi Daniel,

I will try your suggestion and let you know if we get success. Appreciate your help.

Regards,

Varun

Hi Daniel,

Unfortunately suggested approach did not work as service do not have access to Common/OnException. We raised exception but it never invoked handler. Service life cycle ends at service response only. service life cycle to not have access to application level object.

Regards,

Varun.

mvp_badge
MVP

I have a look at it tonight, and try to find out how this can be done.

Hi @Daniël Kuhlmann ,
Can you please post your solution if you've one for the above issue, we're facing the same issue now.

Need to catch the data sending from the POST verb from external(.net) application to my outsystems application.

This is happening like 

I'm hitting other application, doing required job there and upon submission I need to land on my application (while hitting the external app I'm sending return URL), in return they're sending data through POST method but not a query string parameter.

Kindly help on this.


With Regards,

Sandeep.

I don't have a clear understanding of what you are trying to accomplish. If I understand correctly, you want to do a POST call from an external system to an Outsystems application, and then want to see the results of that call on a screen, right?
For now I see 2 solutions:
1. creating an exposed REST api, that recieves the request with all the input variables, and returns a complete html page in the response body
2. creating an exposed REST api, that recieves the request with all the input variables, and store it directly in the database. Then create a seperate screen that reads this information from the database. Return a url in the response

Hi Bas de Vries,

Current flow is 

1. Outsystems App Screen[say A] posts data with "ReturnURL" to Site ABC

2. User completes its task on Site ABC and press submit button (POST  request initiated on Site ABC for Outsystems app)

3. Request comes back to Outsystems Rest API (currently i have written Rest API to handle the request) but i am not able to redirect response to  Outsystems application page

So, Second option is not what we can do because it will break the journey. It has to be synchronous flow.

However, i did like first option (i.e. creating an exposed REST api, that receives the request with all the input variables, and returns a complete html page in the response body). I tried to set html content in response body, but it display HTML text as it is. Rather i would need to give button ot anchor tag so that on clicking i can go back to same page where journey started. 

Please let me know how i can returns a complete html page in the response body of REST API to display.

Hi Varun,

were you able to fix your issue for the above discussion, if so can you please post the solution here.


With Regards,

Sandeep.

Hi Sandeep,

There is no natural solution here. However, we have implemented a workaround. I am not very proud of such solution but it worked for my requirement.

1. Write REST service accepting POST in Outsystems and use this Outsystems service url for redirection from external(.net) application. As soon as post request is received from external(.net) application, update DB. Assuming there is some key in request and response.

From UI perspective:

2. Open external(.net) application in new window from Outsystems page using javascript 

3. Run javascript timer on Outsystems page in the background infinitely and in every interval checking DB status for data submission (from external .net application). Show hourglass till the time DB is updated with service response

4. As soon as POST request is received and DB got updated (through service in step 1), terminate the wait and render as required (you might have to query DB to retrieve some data received in POST back).

Regards,

Varun Singh

Hi Sandeep,

You can avoid to use javascript timer with slight change.

Write REST service accepting POST in Outsystems and use this Outsystems service url for redirection from external(.net) application. As soon as post request is received from external(.net) application, fetch post paramaters and set it in request parameter of destination page in the location header.

courtesy: Amal Raj (MVP)

Thanks,

Varun

Hi Varun,

thanks for the response we tried the same from our end but redirection is happening properly, I'll attach OAP for your reference , Please tell us if any modifications required .

Note: I didn't used GetRequest method because I don't require the data coming from the other end, It's fine if I can handle the POST request and redirection happens properly.

With Regards,

Sandeep.

TestRedirection.oap


Correction : Redirection is not happening properly 

I had the same requirement for a usecase.

I ended up writing an outsystems extension to read the post data out of the HttpContext object.


public void MssGetPostData(string ssKey, out string ssValue) {

            try {

                ssValue = HttpContext.Current.Request.Form[ssKey];

            }

            catch {

                ssValue = string.Empty;

            }

}

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.