【问题标题】:Accessing TeamCity using Authenticationn/Access Token gives error 401 Unauthorized使用 Authenticationn/Access Token 访问 TeamCity 会出现错误 401 Unauthorized
【发布时间】:2019-08-08 22:02:31
【问题描述】:

尝试使用身份验证(JetBrains 最近在 TeamCity 中添加的功能)访问 TeamCity。文档很差,没有例子。它只是对我不起作用。

执行 POWERSHELL 命令

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

$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

错误

得到以下错误:

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

谁能帮我标题和/或缺少的任何内容有什么问题?

进一步参考:

TeamCity 2019.1 Help - Managing Access Token

Powershell 6 - Invoke-RestMethod

【问题讨论】:

  • 你试过邮递员吗?
  • @NirajGajjar 是的,它正在与邮递员合作
  • @NirajGajjar ...在“授权”选项卡中,我添加了令牌...在“标题”选项卡中,我在“正文”中添加了 Origin 和 Conten-Type 键及其值' 选项卡,Xml 部分。然后我使用 POST 方法发布 URL:teamcity.my.domain.com/httpAuth/app/rest/buildQueue

标签: powershell teamcity


【解决方案1】:

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

所以解决方法是使用网址http://teamcity.my.domain.com/app/rest/buildQueue/ 而不是http://teamcity.my.domain.com/httpAuth/app/rest/buildQueue/ 因为您使用基于令牌的身份验证。

【讨论】:

    猜你喜欢
    • 2016-11-28
    • 2018-12-31
    • 1970-01-01
    • 2019-03-16
    • 1970-01-01
    • 1970-01-01
    • 2022-11-17
    • 1970-01-01
    • 2018-08-06
    相关资源
    最近更新 更多