Create a project via YouTrackSharp package

Can one create a new project via YouTrackSharp package? Looks like the only exposed projects service is to get accessible projects, butREST API clearly support new project creation 


Ok, I have now been able to create a project resorting to the HttpClient and YouTrackSharp.Generated objects, i.e. no longer using the ProjectsService. But now I have a new issue - how do I add a CustomField to my project? I can do it in PostMan:

But my c# code throws  below error

{"error":"Cannot interpret value as jetbrains.youtrack.gaprest.db.DatabaseEntity","error_description":"Error in field unknown","error_developer_message":"Error in field unknown","error_field":"unknown"}

 Here is the code: - the error is from the ytc.AdminProjectsCustomfieldsPostAsync method

        public YouTrackSharp.Projects.CustomField CreateProjectCustomFields(string projectId)
            //Add Ckey and TemplateVersion to MyNewProject598

            var httpClient = new HttpClient();
            httpClient.BaseAddress = new Uri(_baseUrl + $"/api/admin/projects/{projectId}/customFields?fields=field(name,id)");
            httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", _token);

            var ytc = new YouTrackSharp.Generated.YouTrackClient(httpClient);
            // Note: custom fields are added 1 at a time to the project
            var cf = new YouTrackSharp.Generated.CustomField()
                Name = "CKey",
                Id = "92-18",
                FieldType = new YouTrackSharp.Generated.FieldType() { Id = "Text" }

            var bcf = new YouTrackSharp.Generated.BundleProjectCustomField()
                Field = cf,
                IsPublic = true,
                CanBeEmpty = false,

            var ncf = ytc.AdminProjectsCustomfieldsPostAsync("ProjectCKey", "id", bcf).Result;

            var customField = new CustomField()
                Name = ncf.Field.Name,
                Id = ncf.Id

            return customField;




Thank you for contacting YouTrack community forums. I'm afraid adding custom fields via YouTrackSharp is not supported yet. I will discuss with the responsible developer if it's something we can add quickly and get back to you with the update. 


Hi again,

I appreciate your patience. Let me please explain how you can add a custom field:

1. First of all, for text fields please use the following type (SimpleProjectCustomField):

var bcf = new YouTrackSharp.Generated.SimpleProjectCustomField()

2. Next, you can use YouTrack's REST API to create fields without using the additional httpClient() level, it should work as follows:

var connection = new BearerTokenConnection(_baseUrl, _token);
var client = await connection.GetAuthenticatedApiClient();
var ncf = client.AdminProjectsCustomfieldsPostAsync("ProjectCKey", "id", bcf).Result;

Hope it helps. 


Please sign in to leave a comment.