Closed thgossler closed 4 years ago
thx for reporting! We will check this.
@tgossler it seems to me that there is an issue for this and it does not seem to be a problem of the module, but the API. But I will check more
I checked a bit more and something is mixed up in your requirements.
You said in expected behaviour that a project should be created, but the API you are using is for working with repositories and forks.
In case you meant repository then also there is not an example that uses the name of the project with a new repository. Instead, the project Id is requested. If you changed your code to
$vstsProjectName = "project name with spaces"
Set-VSTeamAccount -Account $vstsAccountName -PersonalAccessToken $personalAccessToken
Set-VSTeamDefaultProject -Project $vstsProjectName
$project = Get-VSTeamProject -Name $vstsProjectName
$jsonBodyObject = @{
name = $repoName
project = @{
id = $project.ID
}
}
$jsonBody = ConvertTo-Json -InputObject $jsonBodyObject
$repo = Invoke-VSTeamRequest -Method Post -Area git -Resource repositories -Body $jsonBody -ContentType 'application/json' -version '5.1-preview'
then the repository is created successfully.
If you intended to create a project, then you should use Add-VSTeamProject.
I am closing this as it seems to me that it is a wrong use of the API due to a probably inconsistent API and bad documentation.
Hi,
you are right, I meant creating repos not projects.
I have tested this but it seems not to work. Do you seen an error in my code (see )?
[cid:image003.jpg@01D6488E.11A9B9A0]
From: Sebastian Schütze notifications@github.com Sent: Friday, June 19, 2020 7:47 PM To: DarqueWarrior/vsteam vsteam@noreply.github.com Cc: Gossler, Thomas (SHS DI DH TP PL) thomas.gossler@siemens-healthineers.com; Mention mention@noreply.github.com Subject: Re: [DarqueWarrior/vsteam] Project name with spaces causing problems (#334)
I checked a bit more and something is mixed up in your requirements.
You said in expected behaviour that a project should be created, but the API you are using is for working with repositories and forks.
In case you meant repository then also there is not an example that uses the name of the project with a new repository. Instead, the project Id is requested. If you changed your code to
$vstsProjectName = "project name with spaces"
Set-VSTeamAccount -Account $vstsAccountName -PersonalAccessToken $personalAccessToken
Set-VSTeamDefaultProject -Project $vstsProjectName
$project = Get-VSTeamProject -Name $vstsProjectName
$jsonBodyObject = @{
name = $repoName
project = @{
id = $project.ID
}
}
$jsonBody = ConvertTo-Json -InputObject $jsonBodyObject
$repo = Invoke-VSTeamRequest -Method Post -Area git -Resource repositories -Body $jsonBody -ContentType 'application/json' -version '5.1-preview'
then the repository is created successfully.
If you intended to create a project, then you should use Add-VSTeamProject.
I am closing this as it seems to me that it is a wrong use of the API due to a probably inconsistent API and bad documentation.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/DarqueWarrior/vsteam/issues/334#issuecomment-646788221, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AN2MQJRYQ4A24KTXO7QMWOLRXOP6HANCNFSM4N5U6NIQ.
@tgossler there is no screenshot added. Answering via mail is not the best option when answering GitHub issues. Could you add your screenshot or the code you used?
Sorry, I have added the screenshot above.
Steps to reproduce
Expected behavior
Project is created without error.
Actual behavior
Environment data
OS
Server