Ruby - Savon - JIRA SOAP - 在创建新问题时设置组件

时间:2012-05-20 18:07:49

标签: ruby jira savon

如何在JIRA问题中设置组件?在创建新问题时,我将组件数组设置为idname值。做正确的方法是什么?它也没有取assignee值。

username = 'admin'
password = 'admin'
project = 'Dev'

jira = Savon::Client.new(
  "https://something.com/rpc/soap/jirasoapservice-v2?wsdl"
)

login = jira.request(:login) do |soap|
  soap.body = {
    :in0 => username,
    :in1 => password
  }
end
login = login.to_hash
token = login[:login_response][:login_return]

def createissue jira, token, project, username
response = jira.request(:create_issue) do |soap|
  soap.body = {
    :in0 => token,
    :in1 => {
      :type => "3",
      :assignee => username,
      :project => project,
      :summary => "API Test",
      :description => "Jira's SOAP API test",
      :components => [ 'id' => '10786']
      #:components =>
        { 'components' =>
          { 'id' => '10786',
            'name' => 'General Troubleshooting'}} # tried these
      #:components =>
        { 'id' => '10786',
          'name' => 'General Troubleshooting'} # tried these
      # None of of the above component
      # options is setting component in my issue.
      # I have the correct 'id' and 'name'.
        }
  }
end
end

  createissue jira, token, project, username

在SOAPUI中,它显示了所需的数据类型,但我为此构建了xml?

<components
  xsi:type="jir:ArrayOf_tns1_RemoteComponent"
  soapenc:arrayType="bean:RemoteComponent[]"
  xmlns:jir="https://server/rpc/soap/jirasoapservice-v2" />

1 个答案:

答案 0 :(得分:0)

不是最优雅的方式,但如果遇到这样的问题,我的出发点是在代码中构建XML字符串并将其分配给soap.body。