{"action":"created","issue":{"url":"https://api.github.com/repos/instructure/canvas-lms/issues/1233","repository_url":"https://api.github.com/repos/instructure/canvas-lms","labels_url":"https://api.github.com/repos/instructure/canvas-lms/issues/1233/labels{/name}","comments_url":"https://api.github.com/repos/instructure/canvas-lms/issues/1233/comments","events_url":"https://api.github.com/repos/instructure/canvas-lms/issues/1233/events","html_url":"https://github.com/instructure/canvas-lms/issues/1233","id":295873459,"number":1233,"title":"Empty list of unpublished courses","user":{"login":"sefanja","id":12880972,"avatar_url":"https://avatars1.githubusercontent.com/u/12880972?v=4","gravatar_id":"","url":"https://api.github.com/users/sefanja","html_url":"https://github.com/sefanja","followers_url":"https://api.github.com/users/sefanja/followers","following_url":"https://api.github.com/users/sefanja/following{/other_user}","gists_url":"https://api.github.com/users/sefanja/gists{/gist_id}","starred_url":"https://api.github.com/users/sefanja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sefanja/subscriptions","organizations_url":"https://api.github.com/users/sefanja/orgs","repos_url":"https://api.github.com/users/sefanja/repos","events_url":"https://api.github.com/users/sefanja/events{/privacy}","received_events_url":"https://api.github.com/users/sefanja/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-02-09T13:37:13Z","updated_at":"2018-03-07T21:42:37Z","closed_at":null,"author_association":"NONE","body":"### Summary:\r\n`GET /api/v1/accounts/1/courses?state[]=unpublished` returns an empty list instead of a list of unpublished courses.\r\n\r\n### Steps to reproduce:\r\n 1. Create a new course (default workflow state will be 'unpublished')\r\n 2. Go to `/api/v1/accounts/1/courses?state[]=unpublished`\r\n\r\n### Expected behavior:\r\nA list of unpublished courses.\r\n\r\nThe API does return these courses if I omit `?state[]=unpublished`.\r\n\r\n### Additional notes:\r\nDocs: https://canvas.instructure.com/doc/api/accounts.html#method.accounts.courses_api"},"comment":{"url":"https://api.github.com/repos/instructure/canvas-lms/issues/comments/371295255","html_url":"https://github.com/instructure/canvas-lms/issues/1233#issuecomment-371295255","issue_url":"https://api.github.com/repos/instructure/canvas-lms/issues/1233","id":371295255,"user":{"login":"spencerolson","id":6925979,"avatar_url":"https://avatars2.githubusercontent.com/u/6925979?v=4","gravatar_id":"","url":"https://api.github.com/users/spencerolson","html_url":"https://github.com/spencerolson","followers_url":"https://api.github.com/users/spencerolson/followers","following_url":"https://api.github.com/users/spencerolson/following{/other_user}","gists_url":"https://api.github.com/users/spencerolson/gists{/gist_id}","starred_url":"https://api.github.com/users/spencerolson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spencerolson/subscriptions","organizations_url":"https://api.github.com/users/spencerolson/orgs","repos_url":"https://api.github.com/users/spencerolson/repos","events_url":"https://api.github.com/users/spencerolson/events{/privacy}","received_events_url":"https://api.github.com/users/spencerolson/received_events","type":"User","site_admin":false},"created_at":"2018-03-07T21:42:37Z","updated_at":"2018-03-07T21:42:37Z","author_association":"CONTRIBUTOR","body":"Hi @sefanja OK, I think I've figured this one out. Long story short, it looks like you'll need to request states of `created` and `claimed`, instead of `unpublished`.\r\n\r\nPer the documentation that you linked to, available values for state are: `[created, claimed, available, completed, deleted, all]`\r\n\r\nThis can be confusing, because as you mentioned, when omitting`?state[]=unpublished` and making the call to the endpoint, you get back an object with a `workflow_state` of `unpublished`, so you'd logically think you can request courses with state of `unpublished`. However, this is the code that is used to determine that return value of `unpublished` that you get back:\r\n\r\n  ```\r\n  def api_state\r\n    return 'unpublished' if workflow_state == 'created' || workflow_state == 'claimed'\r\n    workflow_state\r\n  end\r\n```\r\n\r\nEssentially, in the cases where the course's workflow_state is \"claimed\" or \"created\", we return \"unpublished\" in the API response. So, with all that in mind, knowing that the unpublished course actually has a workflow_state of \"claimed\" or \"created\" (i believe in the example you mentioned the workflow_state will be \"claimed\"), you want to request `state`s of `claimed` and `created` to get unpublished courses.\r\n\r\nHope this helps!\r\nSpencer"}}
{"actor":{"display_login":"spencerolson"}}