吉拉 API | 错误:“操作值必须是字符串” - 尝试设置嵌套两层深度的值

sco*_*n35 5 ruby hash json nested jira-rest-api

尝试创建特定的新 jira 票证requestType,但它嵌套了两层深。尝试了一些可能的改变,但没有运气。这是我的代码,

require 'jira-ruby' # https://github.com/sumoheavy/jira-ruby

options = {
            :username => jira_username,
            :password => jira_password,
            :site     => 'https://jiraurl/rest/api/2/',
            :context_path => '',
            :auth_type => :basic,
            :read_timeout => 120
          }

client = JIRA::Client.new(options)
issue = client.Issue.build
fields_options = { 
  "fields" => 
  {
    "summary"   => "Test ticket creation",
    "description" => "Ticket created from Ruby",
    "project"   => {"key" => "AwesomeProject"},
    "issuetype" => {"name" => "Task"},
    "priority" => {"name" => "P1"},
    "customfield_23070" => 
    {
      "requestType" => {
        "name" => "Awesome Request Type"
      }
    }
  }
}
issue.save(fields_options)
Run Code Online (Sandbox Code Playgroud)

"errors"=>{"customfield_23070"=>"Operation value must be a string"}

还尝试将JSON对象传递给customfield_23070"customfield_23070": { "requestType": { "name": "Awesome Request Type" } } 仍然没有运气,得到相同的错误消息。

如果有帮助的话,这就是customfield_23070我们的 Jira 中的样子, 在此输入图像描述

requestType请问有谁知道这种情况如何设置吗?任何帮助是极大的赞赏!!

小智 10

似乎对于具有特定数据类型(字符串/数字)的自定义字段,您必须将值传递为:

"customfield_1111": 1
Run Code Online (Sandbox Code Playgroud)

或者:

"customfield_1111": "string"
Run Code Online (Sandbox Code Playgroud)

代替:

"customfield_1111":{ "value": 1 }
Run Code Online (Sandbox Code Playgroud)

或者:

"customfield_1111":{ "value": "string" }
Run Code Online (Sandbox Code Playgroud)


小智 0

我不确定,但你可以尝试这个可能的例子:

例如1:

"customfield_23070"=>{"name"=>"requestType","value"=>"Awesome Request Type"}
Run Code Online (Sandbox Code Playgroud)

例如2:

"customfield_23070"=>{"requestType"=>"Awesome Request Type"}
Run Code Online (Sandbox Code Playgroud)

例如3:

"customfield_23070"=>{"value"=>"Awesome Request Type"}
Run Code Online (Sandbox Code Playgroud)

例4

"customfield_23070"=>{"name"=>"Awesome Request Type"}
Run Code Online (Sandbox Code Playgroud)