CreatePushAsync不起作用:VssServiceException:提供的参数无效。参数名称:newPush

时间:2019-06-20 12:58:27

标签: c# rest azure-devops

我正在尝试复制文档https://docs.microsoft.com/en-us/rest/api/azure/devops/git/pushes/create?view=azure-devops-rest-5.0#update_a_file

中给出的发帖请求

使用.Net库进行扩展。

我通过反复试验检查了refUpdate和OldObjectId是否正确。 更改,项目,仓库都已定义,并且不为空。

   GitPush push = new GitPush();
   GitCommit gitCommit = new GitCommit();
   GitChange change = new GitChange();
   ItemContent content = new ItemContent();
   content.Content = changeString;
   content.ContentType = ItemContentType.RawText;
   change.NewContent = new ItemContent();
   change.ChangeType = VersionControlChangeType.Edit;
   change.Item = item;
   List<GitChange> changes = new List<GitChange>();
   changes.Add(change);
   gitCommit.Changes = changes;
   gitCommit.Comment = "updated app.cpp";
   GitRefUpdate refUpdate = new GitRefUpdate();
   refUpdate.Name = "refs/heads/dev";
   refUpdate.OldObjectId = oldObjectId;
   List<GitCommit> commits = new List<GitCommit>();
   commits.Add(gitCommit);
   List<GitRefUpdate> refUpdates = new List<GitRefUpdate>();
   refUpdates.Add(refUpdate);
   push.Commits = commits;
   push.RefUpdates = refUpdates;
   GitPush pushed = gitClient.CreatePushAsync(push, repo.Id).Result;

最后一行,调试器给出了一个例外,即未定义参数“ newPush”。

0 个答案:

没有答案