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

Fetching tasks give an invalid endpoint error #12

Closed
matthijsgroen opened this issue Sep 26, 2014 · 8 comments
Closed

Fetching tasks give an invalid endpoint error #12

matthijsgroen opened this issue Sep 26, 2014 · 8 comments

Comments

@matthijsgroen
Copy link

When fetching a story, and calling story.tasks the code gives an error:

{:status=>404, :headers=>{"server"=>"nginx/1.6.0", "date"=>"Fri, 26 Sep 2014 06:22:49 GMT", "content-type"=>"application/octet-stream", "content-length"=>"135", "connection"=>"close", "etag"=>"\"5314f7e6-87\""}, :body=>{"code"=>"route_not_found", "error"=>"The path you requested has no valid endpoint.", "kind"=>"error", "http_status"=>"404"}}
tracker_api-0.2.5/lib/tracker_api/client.rb:162:in `rescue in request'
tracker_api-0.2.5/lib/tracker_api/client.rb:149:in `request'
tracker_api-0.2.5/lib/tracker_api/client.rb:70:in `paginate'
tracker_api-0.2.5/lib/tracker_api/endpoints/tasks.rb:11:in `get'
tracker_api-0.2.5/lib/tracker_api/resources/story.rb:43:in `tasks'

It does not matter if you include tasks in the list of fields when fetching a story.

@matthijsgroen
Copy link
Author

@forest
Copy link
Contributor

forest commented Sep 29, 2014

I re-ran the specs for getting tasks and it is working. If you delete the vcr/cassette for getting tasks the spec will make real requests to the test project.

https://github.com/dashofcode/tracker_api/blob/master/test/story_test.rb#L12

Are you sure you have the project_id and story_id correct?

@matthijsgroen
Copy link
Author

Yeah these should by fine, I used the following code:

  stories = project.stories(with_state: 'unstarted', fields: 'name,story_type,owners')
  stories.each do |story|
    story.tasks
  end

But I will try by using project.story('id').tasks instead

@forest
Copy link
Contributor

forest commented Sep 29, 2014

Hmmm. That should work. I'll try to dig in a bit more this week.

@matthijsgroen
Copy link
Author

project.story('id').tasks this syntax works, only downside is there seems to be no story.project, so I have to pass around to project to get the tasks. But I'm no longer impeded. Thanks!

(not having story.tasks work is still an issue offcourse)

@matthijsgroen
Copy link
Author

I've found what is causing this, I specify the fields I want from a userstory. When I do not ask for the project_id it is not assigned to the story when asking project.stories. This way the request to ask for the tasks fails because it does not know the project id (which could be assigned beforehand since the stories are asked from the project in the first place)

@matthijsgroen
Copy link
Author

See https://github.com/dashofcode/tracker_api/blob/master/lib/tracker_api/endpoints/stories.rb#L14

Changing it into: data.map { |story| Resources::Story.new({ client: client, project_id: project_id }.merge(story)) } could solve it

@forest
Copy link
Contributor

forest commented Oct 18, 2014

Good find. I'll add some specs to make sure I can break it by excluding the project_id and then make the fix.

@forest forest closed this as completed in 7aa439b Oct 18, 2014
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

No branches or pull requests

2 participants