REST API - how to set "Submitted by" field?

Hello guys,

I noticed that bug reports which are sent by YouTrack when it crashes are all submitted by "Exception Robot" user. I'm wondering if it's possible to set submitter either at the issue creation time (using /rest/issue/ POST request), or later, using commands with /rest/issue/execute/ request?

I think it would be quite natural that logged  user would be used as a submitter but seems it's a bug in the API, and I already submitted a bug: http://youtrack.jetbrains.net/issue/JT-2435.

Just wondering how you do this for Exception Robot's issues ;-)

Thanks,

Alexey

0
1 comment
Avatar
Permanently deleted user

will answer myself - you need to login to the REST service (/rest/user/login) with desired user credentials. For the POST request, server will respond with 200 OK with "Set-Cookie" header. That header contains the cookie which must be reused in the following POST requests.

In C# this can be easily achieved with CookieContainer:

        readonly CookieContainer _cookieJar = new CookieContainer();

        // use this function to create POST requests for Login and all consequent operations
        private HttpWebRequest GetPostRequest(string url)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "POST";
            request.KeepAlive = true;
            request.ContentType = "application/x-www-form-urlencoded";
            request.CookieContainer = _cookieJar;
            return request;
        }

It will be automatically filled with the cookies from the http response.

Alexey.

0

Please sign in to leave a comment.