简体   繁体   中英

create issue in Jira API using Ruby rest client

I'm trying to create an issue in Jira using rest-client in ruby, I'm new to this method (used only postman until now) and I don't understand the "url,payload,headers" structure - below under "fields" is my "payload" or the fields I want to send, I was not able to succeed sending a successfull post request using rest - client and appreciate all help given :)

url = 'my_url'

response = RestClient::Request.new(
    :method => :post,
    :url => url,
    :user => 'username',
    :password => 'pasword',
    :fields => {
      :project => {:id => 'some_id'},
      :issuetype => {:id => 'some_type_id'},
      :reporter => {:name => 'some_name'},
      :components => [{:id => 'some_comp_id'}]
    },
    :headers => { :content_type => :json },
  ).execute
  results = JSON.parse(response.to_str, symbolize_names: true)

PS - I did not share the error response due to the fact that every time I change something I seem to get a different one, my problem is in the syntax I think and the misunderstanding of the proper structure of this request.

Current error is - 415 Unsupported Media Type

Have you tried changing fields to payload ?

Looking at the code and specs for the RestClient project it doesn't appear to be a valid field.

If not I would suggest reading my comment on the post as it can be any number of things.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM