c# - CreatePushAsync 不起作用:VssServiceException:提供的参数无效。参数名称:newPush
问题描述
我正在尝试复制文档中给出的发布请求: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”未定义的异常。
解决方案
推荐阅读
- android - 有 Nativescript Jalali 日历插件吗?(或者我怎样才能将波斯(Jalali)日期提供给 RadCalendar 以显示?)
- python - 如何在熊猫中过滤 groupby 对象
- javascript - 从不使用 JSON.parse 的子字符串中获取数字
- php - PHP Regex 从路径中获得第二次出现
- r - 编织 rmarkdown 文档时 MiKTeX 失败
- css - 引导响应列冲突
- python - 如何从股票交易所等网站持续获取数据并使用 python 将其发送到 azure event hub?
- c++ - std::forward 中的模板推导失败?
- c++ - c++14通过引用返回值优化性能
- c# - “ConfigurationBuilder”不包含“AddJsonFile”的定义