参数组合无效或不完整。\r\nParameter 名称:tagObject VSTS Git API
The combination of parameters is either not valid or not complete.\r\nParameter name: tagObject VSTS Git API
我尝试使用 GitHttpClient CreateAnnotatedTagAsync 方法 (Microsoft.TeamFoundation.SourceControl.WebApi) 将标签附加到现有提交。但每次我不断收到错误消息:
The combination of parameters is either not valid or not complete.\r\nParameter name: tagObject
添加注释标签的部分代码。
GitObject gitObject = new GitObject { ObjectId = commitId, ObjectType = GitObjectType.Commit };
GitAnnotatedTag tagObj = new GitAnnotatedTag
{
Name = tagName.Replace(' ', '_'),
TaggedObject = gitObject,
TaggedBy = new GitUserDate
{
Name = "FirstName LastName",
Email = "someemail@smth.com",
Date = DateTime.Now
},
Message = tagComment
};
GitAnnotatedTag res = gitClient.CreateAnnotatedTagAsync(tagObj, projectName, new Guid(repositoryId)).Result;
我尝试发送的标签对象示例:
如有任何帮助,我们将不胜感激。
所以我只是使用 API 创建标签:
GitAnnotatedTag tag = null;
try
{
var tagObject = new { Name = tagName.Replace(' ', '_'), Message = tagComment, TaggedObjectId = commitId };
StringContent stringContent = new StringContent(JsonConvert.SerializeObject(tagObject),
Encoding.UTF8,
"application/json");
client.DefaultRequestHeaders.Add("Accept", "application/json; charset=utf-8; api-version=3.2-preview.1");
using (HttpResponseMessage response = client.PostAsync(string.Format(createTagUrl, projectId, repositoryId), stringContent).Result)
{
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
tag = JsonConvert.DeserializeObject<GitAnnotatedTag>(responseBody);
}
}
catch (Exception ex)
{
// Add some error handling here
}
return tag;
我尝试使用 GitHttpClient CreateAnnotatedTagAsync 方法 (Microsoft.TeamFoundation.SourceControl.WebApi) 将标签附加到现有提交。但每次我不断收到错误消息:
The combination of parameters is either not valid or not complete.\r\nParameter name: tagObject
添加注释标签的部分代码。
GitObject gitObject = new GitObject { ObjectId = commitId, ObjectType = GitObjectType.Commit };
GitAnnotatedTag tagObj = new GitAnnotatedTag
{
Name = tagName.Replace(' ', '_'),
TaggedObject = gitObject,
TaggedBy = new GitUserDate
{
Name = "FirstName LastName",
Email = "someemail@smth.com",
Date = DateTime.Now
},
Message = tagComment
};
GitAnnotatedTag res = gitClient.CreateAnnotatedTagAsync(tagObj, projectName, new Guid(repositoryId)).Result;
我尝试发送的标签对象示例:
如有任何帮助,我们将不胜感激。
所以我只是使用 API 创建标签:
GitAnnotatedTag tag = null;
try
{
var tagObject = new { Name = tagName.Replace(' ', '_'), Message = tagComment, TaggedObjectId = commitId };
StringContent stringContent = new StringContent(JsonConvert.SerializeObject(tagObject),
Encoding.UTF8,
"application/json");
client.DefaultRequestHeaders.Add("Accept", "application/json; charset=utf-8; api-version=3.2-preview.1");
using (HttpResponseMessage response = client.PostAsync(string.Format(createTagUrl, projectId, repositoryId), stringContent).Result)
{
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
tag = JsonConvert.DeserializeObject<GitAnnotatedTag>(responseBody);
}
}
catch (Exception ex)
{
// Add some error handling here
}
return tag;