I built a web api on .Net, and now to consume it, I need to send a cookie with the authorization token. In this video the work is done using Fiddler and it seems to be easy. How do I achieve this in Outsystems? I'm still using 9.1 version.
Hi Samy,
You have 2 ways of adding cookies: either just adding a header called "cookies" to your request or going in OnBeforeRequestAdvanced and add it in C#/Java on the request.
But I looked at the video that you liked and fiddler UI is actually very misleading. Note that it says "Cookie / Login" ...and it that section it includes more than just cookies.
What you actually need is a header called "authorization" with that value, not really a cookie.
The easier way to add a header is at the client level, by adding an input with Send In Header on your action or inside a OnBeforeRequest callback.
Regards,João Rosado
João Rosado wrote:
Thank you for your reply
Using PostMan client, I already tried to add just a header called authorization and it failed to connect saying "Authorization has been denied for this request". I then made this topic on Stack Overflow asking about the failure, and the answer was that my web api out of the box authentication is cookie based. That's why I am asking then, how I make this approach to work consuming the api through Outsystems.
After reading my code on Stack Overflow, you still think that I could connect without a cookie?
Well, I personally never tried to create a owin rest server, so I'm not sure what some of that code is doing.
The only pointer that I can say is that what the video is showing has nothing to do with cookies.
Regards,João Rosado
SamyCode wrote:
Samy,
I created a screencast where you can see how we can authenticate using rest api in OutSystems.
Using header authentication and body used for send some information to the rest api
Rest With Header Authentication
Any doubt dont hesitate to contact .. :-)
PS.: Execute the html file locally (VirusFree)
Updated: Rest With Header Authentication (with html/swf included to see locally)
CMateus wrote:
Hi,can you show me the screencast
owen chen wrote:
Hi Owen,
New version of OutSystems FAQ is pretty straight forward on how to use custom authentication.
Add Custom Authentication to an Exposed REST API
If you need something more specific, let me know.
Cheers
Thanks for your reply,
But Now I want to consume a API which is created on .net platform, not expose API
Did you already look into this faq?
Consume a REST API
Or gimme a example what are you trying to do
Consume a REST API from or to .NET Platform ?
Client (.net) >> OutSystems REST (exposed)?
OutSystems REST (consume) >> .NET Rest API (exposed)?
I want do this ===>OutSystems REST (consume) >> .NET Rest API (exposed)
Look at Item 5.Just set-up the header and you can consume with no problem.Of course .NET side need to deal with it.
But later I can make screencast again if need it ok?
Yes,I need, Thanks!