Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue.save for new issues #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shortdudey123
Copy link
Contributor

If the issue is new, then the fields are not being updated, they are being created.

new_issue_data = {
  'fields' => {
    'reporter' => {
      'name' => 'username'
    },
    'project' => {
      'key' => 'KEY'
    },
    'issuetype' => {
      'name' => 'Task'
    },
    'summary' => 'Testing ticket',
    'description' => 'blah blah blah'
  }
}

new_issue = Jiralicious::Issue.new(new_issue_data)
saved_issue = new_issue.save!

The above code results in 400 from Jira due to the fields hash being empty

Jiralicious::TransitionError: #<HTTParty::Response:0x7ffd32d57730 parsed_response={"errorMessages"=>[], "errors"=>{"project"=>"project is required"}}, @response=#<Net::HTTPBadRequest 400 Bad Request readbody=true>, ...

Options hash from just before the API call in Jiralicious::Base#fetch

{:method=>:post, :body=>{"fields"=>{}}, :body_uri=>{"fields"=>{}}, :url_uri=>"https://example.atlassian.net/rest/api/latest/issue/"}

If the issue is new, then the fields are not being updated, they are being created.

```
new_issue_data = {
  'fields' => {
    'reporter' => {
      'name' => 'username'
    },
    'project' => {
      'key' => 'KEY'
    },
    'issuetype' => {
      'name' => 'Task'
    },
    'summary' => 'Testing ticket',
    'description' => 'blah blah blah'
  }
}

new_issue = Jiralicious::Issue.new(new_issue_data)
saved_issue = new_issue.save!
```

The above code results in 400 from Jira due to the fields hash being empty
```
Jiralicious::TransitionError: #<HTTParty::Response:0x7ffd32d57730 parsed_response={"errorMessages"=>[], "errors"=>{"project"=>"project is required"}}, @response=#<Net::HTTPBadRequest 400 Bad Request readbody=true>, ...
```

Options hash from just before the API call in `Jiralicious::Base#fetch`
```
{:method=>:post, :body=>{"fields"=>{}}, :body_uri=>{"fields"=>{}}, :url_uri=>"https://example.atlassian.net/rest/api/latest/issue/"}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant