Can not update submodule using GitHttpClient

I try to create a new branch with submodule change Microsoft.TeamFoundation.SourceControl.WebApi.GitHttpClient but get an error: Expected a Blob, but objected [previous-submodule-value] resolved to a Commit (path ‘/external/[submodule-name]’). So, as we can see it wants to get a commit, but as I see there is no way to pass it there like this.
Here is how I do it:
gitClient.CreatePushAsync(new GitPush
{
RefUpdates = new List<GitRefUpdate>
{
new GitRefUpdate { Name = "refs/heads/[new-branch-name]", OldObjectId = baseBranch.ObjectId }
},
Commits = new List<GitCommitRef>
{
new GitCommitRef
{
Comment = "Bump submodule",
Changes = new List<GitChange>
{
new GitChange
{
ChangeType = VersionControlChangeType.Edit,
Item = new GitItem { Path = "/external/[submodule-name]" },
NewContent = new ItemContent { Content = newHash, ContentType = ItemContentType.RawText }
}
}
}
}
}, [repo-id]);
I've tried some luck on developer-community, and you may find different useful discussions and links there (if needed), and I was redirected to ask it here. Here is a link to that discussion: https://developercommunity.visualstudio.com/t/Can-not-update-submodule-using-GitHttpCl/1537646?viewtype=all
We are experiencing the same issue. Even when you obtain Item via client.GetItemAsync and try to update the content it raised Expected a Blob, but objectId ** resolved to a Commit. For some reason the backend seems to misinterpret the submodule item as a commit. I found this https://stackoverflow.com/questions/22764951/how-do-i-update-a-git-submodule-without-checking-it-out to update the submodule via commandline.
dev.azure does show the content of the item in a format we should be able to update as text in the commit window of adding the submodules.
Hi @Tom de Goede
Thanks for your reply. Yeah, it should help, but this flow requires cloning a repository, but with only api access, it should have been able to run without this extra step.