Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';t使用RESTAPI更新jira问题_Rest_Powershell_Jira_Jira Rest Api - Fatal编程技术网

Can';t使用RESTAPI更新jira问题

Can';t使用RESTAPI更新jira问题,rest,powershell,jira,jira-rest-api,Rest,Powershell,Jira,Jira Rest Api,我正在尝试使用powershell执行此操作,但我收到400个错误: $RESTURL = 'https://mycomp.atlassian.net/rest/api/latest/issue/PROJ-61' $body = '{"fields":{"assignee":{"name":"me"}}}' $restcreds = [System.Convert]::ToBase64String( [System.Text.Encoding]::ASCII.GetBytes(('me' + "

我正在尝试使用powershell执行此操作,但我收到400个错误:

$RESTURL = 'https://mycomp.atlassian.net/rest/api/latest/issue/PROJ-61'
$body = '{"fields":{"assignee":{"name":"me"}}}'
$restcreds = [System.Convert]::ToBase64String(
[System.Text.Encoding]::ASCII.GetBytes(('me' + ":" + 'mypass123'))
)
$httpheader = @{Authorization = "Basic $restcreds"}
$restParameters = @{
Uri = $RESTURL;
ContentType = "application/json";
Method = "PUT";
Headers = $httpheader;
Body = $body;
}
Invoke-RestMethod @restParameters
如果我从请求中删除“body”并将其更改为get,我将成功地获取数据。似乎我只是得到了修改票

如果你得到了一个400(错误的请求),那么这意味着你的请求体有问题

响应正文将包含一条更详细的错误消息,并将明确您必须修复的内容

如果没有错误消息,我只能猜测: 我不确定将assignee设置为“我”是否有效,除非“我”确实是用户的名称。如果您尝试使用完整的用户名,或者使用“key”而不是“name”,会发生什么情况


GET请求工作正常这一事实表明您的凭据是正确的,因此这不是身份验证问题。

我的请求正文没有问题,问题是“我”的受让人不存在(我有一个打字错误)。我发现这个问题解释了如何让PS输出请求体(这就是我发现错误的原因)