【发布时间】: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
谁能帮我标题和/或缺少的任何内容有什么问题?
进一步参考:
【问题讨论】:
-
你试过邮递员吗?
-
@NirajGajjar 是的,它正在与邮递员合作
-
@NirajGajjar ...在“授权”选项卡中,我添加了令牌...在“标题”选项卡中,我在“正文”中添加了 Origin 和 Conten-Type 键及其值' 选项卡,Xml 部分。然后我使用 POST 方法发布 URL:teamcity.my.domain.com/httpAuth/app/rest/buildQueue
标签: powershell teamcity