【问题标题】:Perl script with JIRA REST-API to create JIRA along with custom fieldPerl 脚本与 JIRA REST-API 一起创建 JIRA 以及自定义字段
【发布时间】:2018-07-20 07:02:44
【问题描述】:

我们无法通过 Perl 脚本使用 REST-API 在 Jira 中创建新票证。

注意:没有成功执行自定义字段脚本。请提供在我的脚本中添加自定义字段的建议。

自定义字段的屏幕截图。

错误信息:

JIRA::REST 错误[400 - 错误请求]: - [custom_field] 无法设置字段“custom_field”。它不在相应的屏幕上,或者在 copy_of_new-jira.pl 第 16 行上的 unknown.

Perl 脚本:

#Loading the modules from a specific location such that JIRA::REST.

    use JIRA::Client::Automated;
    use JIRA::REST;
    use Data::Dumper;

  #Login details about Jira server

    my $jira = JIRA::REST->new({
        url      => 'https://xxxxxxxx.xxxxx.com',
        username => 'xxxxxxx',
        password => 'xxxxxxx',
    });

    # Create the ticket using post function 
    my $issue = $jira->POST('/issue', undef, {
        fields => {
            project   => { key => 'TIME' },
            issuetype => { name => 'Task' },
            summary   => '20-7-2018 checking field persent or not',
            description => 'test',
            custom_field => { Epic Link => 'Application Framework'},
        },
    });

【问题讨论】:

  • 你试过custom_field => { 'Epic Link' => 'Application Framework' }吗?
  • 您似乎不应该将自定义字段放入具有自己的哈希引用及其显示名称的 custom_field 键中。相反,直接在fields 哈希中使用字段的内部名称。我不记得命名方案,但这些字段的名称中有很多数字。
  • 感谢您的支持。现在它工作正常。添加到字段后 => { 项目 => { key => 'TIME' },issuetype => { name => 'Task'},summary => '20-7-2018 检查字段是否存在',描述 => 'test', customfield_11197 => 'VIGIL-217' },

标签: perl perl-module jira-rest-api


【解决方案1】:

您的 fields->custom_field 数据结构中似乎缺少一些引号:

# Create the ticket using post function 
my $issue = $jira->POST('/issue', undef, {
    fields => {
        project   => { key => 'TIME' },
        issuetype => { name => 'Task' },
        summary   => '20-7-2018 checking field persent or not',
        description => 'test',
        custom_field => { 'Epic Link' => 'Application Framework'},
    },
});

summary 中也有一个错字,但想必这没什么大不了的。

【讨论】:

  • 我仍然面临同样的错误日志。 JIRA::REST 错误 [400 - 错误请求]: - [custom_field] 字段“custom_field”无法设置。它不在适当的屏幕上,或未知。在 copy_of_new-jira.pl 第 15 行。 >> /usr/lib64/perl5/Crypt/SSLeay.pm:37: sub Crypt::SSLeay::CTX::DESTROY { shift->free; }
  • 感谢您的支持。现在它工作正常。添加到字段后 => { 项目 => { key => 'TIME' },issuetype => { name => 'Task'},summary => '20-7-2018 检查字段是否存在',描述 => 'test', customfield_11197 => 'VIGIL-217' }
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-02
  • 1970-01-01
  • 1970-01-01
  • 2015-01-17
相关资源
最近更新 更多