Is there a way to get the Action name on an Exposed REST API
Application Type
Traditional Web
Service Studio Version
11.54.22 (Build 62709)
Platform Version
11.18.1 (Build 37828)

I need to get the Action name in an exposed API in OnRequest and OnResponse.

It can't be done in this case using the URL to extract the name because the URL has a diferent formatting (something like "/v1/documents/{Id}/etc....)

I've searching the forge and forums, all i could find using the REST Extensability APIs is for consumed APIs and the ActionInfo component only works if i call it inside the action and not in OnRequest and OnResponse. 

Is there any way to do this?

Have you tried using the various Get... server actions of the HTTPRequestHandler API yet?

What do you want to achieve with the action name? If it's about version differentiation (V1, V2, ...), you could also expose multiple REST APIs and name them e.g. "v1" or "documents_v1" instead of "documents_API". This way each exposed service would have its own OnRequest and OnResponse handler.

I think only possible way to add the method name in header from where you are consuming the API

Consumer part:

Exposed part:

Hi Miguel,

There is one approach you can follow:

Try to use this componente from forge Runtime Context:

The output is something like this

Then you can use on the event onAfterResponse and use logic accordling.

Hope it fits your needs.

Luís Dinis

Returns undefined if i use that method.

The component in the forge mentions GETRestExposeContent but i installed and only get GETRestConsumeContent and this one doesnt seem to work

Hi Miguel,

The name you give your REST service only lives in OutSystems, in your module. The consumer only sees the URL. There is no way to retrieve the "internal" name that you can see in Service Studio.


Here is another approach where you can use in exposed API's:

System component -> HTTPRequestHandler -> GetRequestContent (Gets the content of the current HTTP request.)

Then you can use some substring to this text to achieve what you want.

Hope this way it fits your needs,

Luís Dinis

That only returns the current path, not the name in OutSystems.

Yes Kilian, my approach only works if there Name in Outsystems is equal to url Path like this:

I am wondering Why Miguel needs to know the name in outsystems but as this is an API you should based in the url path, I think.

True, but the OP explicitly wrote:

"It can't be done in this case using the URL to extract the name because the URL has a diferent formatting (something like "/v1/documents/{Id}/etc....)"

so what you are suggesting is explicitly not what he wanted to know...

Hi @Miguel Pereira ,

are you looking for a way that you would not have to add code to any of the actual method logics, or is that fine.

If that is fine, you can add it as a cookie or a header inside your actual method logic.  So this means if you expose 10 methods, you need to do this 10 times, so not sure if this is acceptable.


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