0
我正在開發一個項目,其中需要在Visual Studio Online實例上創建工作項目。我正在使用個人訪問令牌。這會將CreatedBy設置爲我的名字(期望的行爲)。我正在考慮使用Oauth2;但是,我不確定是否有辦法執行此服務器到服務器(非交互式)?任何建議的想法?Visual Studio Online SDK
var personalAccessToken = "PAT Value fro Config"; HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.ASCII.GetBytes(string.Format("{0}:{1}", "", personalAccessToken)))); return client;
PAT是在用戶的安全上下文中創建的。我需要找到一種方法來使用Oauth,而不必涉及UI。所以我正在尋找服務器到服務器身份驗證。
object[] patchDocument = new object[5]; patchDocument[0] = new { op = "add", path = "/fields/System.Title", value = bugTitle }; patchDocument[1] = new { op = "add", path = "/fields/Microsoft.VSTS.TCM.ReproSteps", value = bugReproSteps }; patchDocument[2] = new { op = "add", path = "/fields/Microsoft.VSTS.Common.Priority", value = "1" }; patchDocument[3] = new { op = "add", path = "/fields/Microsoft.VSTS.Common.Severity", value = "2 - High" }; patchDocument[4] = new { op = "add", path = "/fields/System.IterationPath", value = deserializeIteration }; //System.IterationPath string postUrl = $"{_vsoInstanceUrl}/DefaultCollection/ProjectName/_apis/wit/workitems/$Bug?api-version=1.0"; await ExecutePatch(patchDocument.ToArray(), postUrl, "application/json-patch+json");
最好的辦法是研究這個(詢問這裏Q是不是真的,因爲它是如何工作的研究),並嘗試一些東西。如果遇到問題,請返回一些代碼和結果。 https://stackoverflow.com/help/how-to-ask – jdv