How to get the JSESSION cookie in,C#,MVC


I’m trying to add a user into the group using the rest-sharp API but I’m not able to get the JSESSION cookie which I need to post the data. From postman it is getting added automatically but how to get it in code behind in .

Thanks in advance

Are you using our .NET management SDK or are you making API calls to the /groups/{{groupId}}/users/{{userId}} to add them to the group? You should only need an SSWS or OAuth token (issued to an admin with adequate permissions) to make this API call


Actually I’m trying to add a user to a group using the RestSharp API but to add a user I need JSESSIONID the following code I’m using from POSTMAN and it was working fine in localhost but in server I’m not getting the JSESSIONID, Below is the code what I’m using.

var client = new RestClient(“”)
Timeout = -1

            var request = new RestRequest(Method.POST);
            request.AddHeader("Accept", "application/json");
            request.AddHeader("Content-Type", "application/json");
            request.AddHeader("Authorization", "mytoken");

            ArrayList lst = new ArrayList

            tst r = new tst
                groupIds = lst,

                profile = new tst.profile1
                    firstName = "test",
                    lastName = "test",
                    email = "",
                    login = ""

            var str = JsonConvert.SerializeObject(r);

            request.AddParameter("application/json", str, ParameterType.RequestBody);

            var response = client.Execute(request);

client.CookieContainer = new System.Net.CookieContainer();
var authCookie = response.Cookies.First(a => a.Name == “JSESSIONID”);

            request.AddHeader("Cookie", "JSESSIONID=" + authCookie.Value);



Can you please show me a POST example if possible in c#


Hi @andreaskouras ,

Thanks for your time but I have solved it by adding a proxy.


This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.