Powershell 使用Authenticationn/Access令牌访问TeamCity时出现错误401

Powershell 使用Authenticationn/Access令牌访问TeamCity时出现错误401,powershell,teamcity,Powershell,Teamcity,尝试使用身份验证(JetBrains最近添加到TeamCity的功能)访问TeamCity。文档很差,没有示例。这对我来说根本不管用 执行POWERSHELL命令 以下不是我尝试的唯一方法,但作为示例,发布调用rest方法的命令,如: $body="<build branchName=`"development`" rebuildAllDependencies=`"true`"><buildType id=`"DevSandbox_TestArea_PageAutomation

尝试使用身份验证(JetBrains最近添加到TeamCity的功能)访问TeamCity。文档很差,没有示例。这对我来说根本不管用

执行POWERSHELL命令

以下不是我尝试的唯一方法,但作为示例,发布调用rest方法的命令,如:

$body="<build branchName=`"development`" rebuildAllDependencies=`"true`"><buildType id=`"DevSandbox_TestArea_PageAutomation`"/></build>"
Invoke-RestMethod -Uri http://teamcity.my.domain.com/httpAuth/app/rest/buildQueue/ -Method Post -ContentType application/xml -Body $body -Headers @{Origin= 'http://teamcity.my.domain.com'; Authorization= 'Bearer tEamCitYauThtoKen'} -UseBasicParsing
有谁能帮我看看标题和/或缺少的东西有什么问题吗

进一步参考:


只有在使用基本身份验证访问TeamCity服务器时,才需要url中的
/httpAuth/
部分

因此,解决方案是使用url
http://teamcity.my.domain.com/app/rest/buildQueue/
而不是
http://teamcity.my.domain.com/httpAuth/app/rest/buildQueue/

因为您使用基于令牌的身份验证。

只有在使用基本身份验证访问TeamCity服务器时,才需要url中的
/httpAuth/
部分

因此,解决方案是使用url
http://teamcity.my.domain.com/app/rest/buildQueue/
而不是
http://teamcity.my.domain.com/httpAuth/app/rest/buildQueue/

因为您使用基于令牌的身份验证。

您有没有尝试过邮递员?@NirajGajjar是的,它正在使用postman@NirajGajjar ... 在“授权”选项卡中,我添加了令牌。。。在“Headers”选项卡中,我添加了Origin和Conten类型键及其值,并在“Body”选项卡中添加了Xml部分。然后我使用POST方法发布URL:你有没有尝试过邮递员?@NirajGajjar是的,它正在使用postman@NirajGajjar ... 在“授权”选项卡中,我添加了令牌。。。在“Headers”选项卡中,我添加了Origin和Conten类型键及其值,并在“Body”选项卡中添加了Xml部分。然后,我使用POST方法发布URL:
Invoke-RestMethod : The remote server returned an error: (401) Unauthorized.
At line:1 char:1
+ Invoke-RestMethod -Uri http://teamcity.my.domain.com/httpAuth/app/r ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand