Return value in the Header of an HTTP call (POST) in the API

Asked

Viewed 511 times

1

I’m using Postman to make the call at the API. That returns me this result in the body:

inserir a descrição da imagem aqui

that comes from this abstract class:

public abstract class ResponseBase
{
    public long SessionId { get; set; }
}

that after taking the value of the property falls into this class method BasicAuthHttpModule:

 private static void OnApplicationEndRequest(object sender, EventArgs e)
    {
        var response = HttpContext.Current.Response;
        //response.AddHeader("SessionId", )
        if (response.StatusCode == 401)
        {
            response.Headers.Add("WWW-Authenticate",
                string.Format("Basic realm=\"{0}\"", Realm));
        }
    }

How I pass the property value SessionId to the Header of Sponse?

In that class OnApplicationEndRequest I don’t have access to SessionId, do not know where it is stored, to be passed in return and appear the value in Postman.

  • What is this class ResponseBase?

  • @jbueno various actions in the API return Sessionid, their classes inherit this class for access.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.