当前位置:  开发笔记 > 编程语言 > 正文

将工作日志发布到JIRA时需要哪些字段?

如何解决《将工作日志发布到JIRA时需要哪些字段?》经验,为你挑选了1个好方法。

我想通过API发布CSV数据,以编程方式填充我的JIRA数据库.我有URL和身份验证工作,但我一直得到400错误:"错误的请求".我的猜测是我在有效载荷中遗漏了一些必填字段:

{
"comment": "test",
"self": "https://jira.mycompany.com/rest/api/latest/issue/12345",
"started": "2015-12-09T17:29:14.698-0500",
"timeSpent": "1 s",
"timeSpentSeconds": "1"
}

文档有一个示例,但它包含一些看似不适用于POST的字段,例如工作日志ID - 肯定必须由服务器而不是客户端创建.该查询参数都是可选的.

一位用户声称有成功仅用三个字段:comment,started,和timeSpent.我仍然只有那些领域得到400. 在调整时间格式后,另一个做了同样的事情; 我匹配他或她的格式. 其他 用户可以发布使用comment,startedtimeSpentSeconds.

一个常见的问题是适当地设置内容类型; 我相信我已经覆盖了这个,因为如果我使用"application/json"以外的类型,我会得到415"不支持的媒体类型".

我听说有一个特定的产品需要使用API​​进行写入(而不是阅读,它工作正常).如果我们错过了该许可证,我希望收到一条错误信息.

这是代码,稍微调试一下:

// Initialize various parameters
string  url        = baseUrl + "issue/" + issueKey + "/worklog";
var     rawContent = // Double-quote and concatenate parameters, and wrap them in curly brackets
var     client     = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", encodedCreds);
var     content    = new StringContent(rawContent, Encoding.UTF8, "application/json");

// Using POST gives a 400 Bad Request error; are we missing a required field?
var  task     = client.PostAsync(url, content);  task.Wait();
var  response = task.Result;

我错过了必填字段吗?如果我在没有内容的情况下POST或使用无效的字段名称,则返回的错误没有变化.如果JIRA愿意告诉我它期待什么领域但没有得到,或者得到但没有期待,那将是很好的.

非常相似,但专注于500错误.



1> 小智..:

问题不是领域之一:comment,started,和timeSpentSeconds实际上都是不够的.相反,问题是我只用一秒钟的时间进行测试.显然,JIRA希望以至少一分钟为单位记录工作,即使它明确跟踪timeSpentSeconds!

这是尝试上传时会得到的确切错误消息(例如)"timeSpentSeconds": 30":

"errorMessages" : ["Worklog must not be null."],
"errors" :
    {
    "timeLogged" : "You must indicate the time spent working."
    }

但是,我能够成功上传本机构的工作:

{ 
"comment": "test",
"started": "2015-12-10T13:45:01.778-0500",
"timeSpentSeconds": "60"
}

对于未来的访问者:我最终放弃了这种方法,因为写入工作日志始终记录在您自己的帐户下.管理员不能使用API​​为其他人记录工作,仅限他或她自己.

推荐阅读
云聪京初瑞子_617
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有