Thanks Dmitry:) that actually works for me too if i change my route from /patients/{patientRef} to /patients/(.*) in the dispatch class. 

My only problem now is that my api specification says the route is /patients/{patientRef} and because we are using the iris api/mgmnt api to auto generate rest classes based on Swagger specification, my dispatch class is auto generated based on .spec class. My .disp class also gets overwritten everytime my .spec class is recompiled.  Any ideas on how to get around this?

Many thanks, 

Utsavi

Thanks Dmitry:) that actually works for me too if i change my route from /patients/{patientRef} to /patients/(.*) in the dispatch class. 

My only problem now is that my api specification says the route is /patients/{patientRef} and because we are using the iris api/mgmnt api to auto generate rest classes based on Swagger specification, my dispatch class is auto generated based on .spec class. My .disp class also gets overwritten everytime my .spec class is recompiled.  Any ideas on how to get around this?

Many thanks, 

Utsavi

Hi Eduard,

I am running in the same issue as Dan and trying out your solution in assumption that there is no other better way of handling this. Overriding OnPreDispatch doesn't seem to work for me. My URL seems decoded by then.

E.g. my API URL is

http://localhost:52773/mapi/admin/v1/patients/{patientReference} where patientReference contains a slash so client call would be something like

http://localhost:52773/mapi/admin/v1/patients/ipm%2F3245678

In my OnPreDisptach pUrl is  already decoded

v1/patients/ipm/3245678 

hence your solution doesn't seem to work. Am I missing something? Is there any  other way of handling this?

Thanks,

Utsavi

Thank you Marc and Eduard for your reply. After spending some time I figured what you both have pointed i.e the class needs to be persistent.

Hi Eduard, 

regarding your comment around moving JSON parsing to BS, is there a reason for doing so? 

I have a common business service which can invoke multiple different Business processes based on a parameter. that is why it uses the common class mapi.core.msg.rq.RestBusinessServiceRequest to pass on request data to the BP and let BP do the specifics. 

Regards,

Utsavi

Hi Dmitry,

Thanks for this article. Do you know how to read the Authorization Header in the `.disp` class and pass it onto the `.impl` class?

As you have mentioned in the article, `.disp` class is auto-generated by `.spec` class and does get over-written everytime `.spec` class is compiled. This makes it tricky to modify the `.disp` class to add some code to get the Authorization Header.  Are you aware of any other ways to get the header ?

Thanks,

Utsavi

Hi Dmitry, 

Thanks for your reply. Yes the OAuth2 token. I haven't setup anything for OAuth2 on IRIS end. In our case, the REST APIs we are building in IRIS are exposed to consumer apps via IAM and Azure. IAM takes care of the OAuth2 Authentication. Client Request then flows through to IRIS which is when I need to introspect the access token to read the "Scope".

I came across the following method, is that something I can utlise?

set sc=##class(%SYS.OAuth2.AccessToken).GetIntrospection("demoresource",accessToken,.jsonObject)