{"action":"created","issue":{"url":"https://api.github.com/repos/GMOD/Apollo/issues/663","labels_url":"https://api.github.com/repos/GMOD/Apollo/issues/663/labels{/name}","comments_url":"https://api.github.com/repos/GMOD/Apollo/issues/663/comments","events_url":"https://api.github.com/repos/GMOD/Apollo/issues/663/events","html_url":"https://github.com/GMOD/Apollo/issues/663","id":115402664,"number":663,"title":"Documentation inconsistency on organism/addOrganism vs required params","user":{"login":"erasche","id":458683,"avatar_url":"https://avatars.githubusercontent.com/u/458683?v=3","gravatar_id":"","url":"https://api.github.com/users/erasche","html_url":"https://github.com/erasche","followers_url":"https://api.github.com/users/erasche/followers","following_url":"https://api.github.com/users/erasche/following{/other_user}","gists_url":"https://api.github.com/users/erasche/gists{/gist_id}","starred_url":"https://api.github.com/users/erasche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erasche/subscriptions","organizations_url":"https://api.github.com/users/erasche/orgs","repos_url":"https://api.github.com/users/erasche/repos","events_url":"https://api.github.com/users/erasche/events{/privacy}","received_events_url":"https://api.github.com/users/erasche/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/GMOD/Apollo/labels/Workingon","name":"Workingon","color":"009800"}],"state":"closed","locked":false,"assignee":{"login":"cmdcolin","id":6511937,"avatar_url":"https://avatars.githubusercontent.com/u/6511937?v=3","gravatar_id":"","url":"https://api.github.com/users/cmdcolin","html_url":"https://github.com/cmdcolin","followers_url":"https://api.github.com/users/cmdcolin/followers","following_url":"https://api.github.com/users/cmdcolin/following{/other_user}","gists_url":"https://api.github.com/users/cmdcolin/gists{/gist_id}","starred_url":"https://api.github.com/users/cmdcolin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmdcolin/subscriptions","organizations_url":"https://api.github.com/users/cmdcolin/orgs","repos_url":"https://api.github.com/users/cmdcolin/repos","events_url":"https://api.github.com/users/cmdcolin/events{/privacy}","received_events_url":"https://api.github.com/users/cmdcolin/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/GMOD/Apollo/milestones/13","html_url":"https://github.com/GMOD/Apollo/milestones/2.0.1","labels_url":"https://api.github.com/repos/GMOD/Apollo/milestones/13/labels","id":1059255,"number":13,"title":"2.0.1","description":"Important issues minimally include:\r\n- proper isoform overlap handling when making changes to genomic feature structure\r\n- track permissions change\r\n- proper session logout (including a possible change of framework libraries)\r\n- some optimizations\r\n","creator":{"login":"nathandunn","id":751274,"avatar_url":"https://avatars.githubusercontent.com/u/751274?v=3","gravatar_id":"","url":"https://api.github.com/users/nathandunn","html_url":"https://github.com/nathandunn","followers_url":"https://api.github.com/users/nathandunn/followers","following_url":"https://api.github.com/users/nathandunn/following{/other_user}","gists_url":"https://api.github.com/users/nathandunn/gists{/gist_id}","starred_url":"https://api.github.com/users/nathandunn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nathandunn/subscriptions","organizations_url":"https://api.github.com/users/nathandunn/orgs","repos_url":"https://api.github.com/users/nathandunn/repos","events_url":"https://api.github.com/users/nathandunn/events{/privacy}","received_events_url":"https://api.github.com/users/nathandunn/received_events","type":"User","site_admin":false},"open_issues":16,"closed_issues":75,"state":"open","created_at":"2015-04-08T21:05:39Z","updated_at":"2015-11-11T00:03:52Z","due_on":"2015-10-22T07:00:00Z","closed_at":null},"comments":8,"created_at":"2015-11-05T23:51:15Z","updated_at":"2015-11-11T00:08:49Z","closed_at":"2015-11-11T00:03:52Z","body":"In addOrganism's controller https://github.com/GMOD/Apollo/blob/master/grails-app/controllers/org/bbop/apollo/OrganismController.groovy#L123 we see the parameter organism, type=json.\r\n\r\nActually sending json encoded/escaped data there fails:\r\n\r\n```\r\ndata={<snip auth>, \"organism\": \"{\\\"directory\\\": \\\"\\\", \\\"publicMode\\\": false, \\\"commonName\\\": \\\"test902\\\"}\"}\r\n```\r\n\r\nfails with error `problem saving organism: org.codehaus.groovy.grails.web.json.JSONException: JSONObject[\"commonName\"] not found.` whereas I would have expected `empty fields detected`.\r\n\r\nI next considered it may expect a json object, instead of a string of a json object inside the parent json blob that gets sent:\r\n\r\n```\r\ndata={<snip auth>, \"organism\": {\"directory\": \"\", \"publicMode\": false, \"commonName\": \"test231\"}}\r\n```\r\n\r\nfailed with the same commonName not found.\r\n\r\nNow on to the test which actually works:\r\n\r\n```\r\ndata={<snip auth>, \"directory\": \"\", \"publicMode\": false, \"commonName\": \"bob52\"}\r\n```\r\n\r\nreturns the expected `problem saving organism: java.lang.Exception: empty fields detected'}`.\r\n\r\nI take this to mean that the controller never expected to receive a JSON object and I'm not 100% sure how it actually functions as such. Between that, and the fact that there's a new, undocumented, mandatory parameter `publicMode`, it seems like the JSON object of the controller should be replaced with the individual parameters passed. That said, I've literally never used grails/groovy in my life so I may be off base here...\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/GMOD/Apollo/issues/comments/155608720","html_url":"https://github.com/GMOD/Apollo/issues/663#issuecomment-155608720","issue_url":"https://api.github.com/repos/GMOD/Apollo/issues/663","id":155608720,"user":{"login":"cmdcolin","id":6511937,"avatar_url":"https://avatars.githubusercontent.com/u/6511937?v=3","gravatar_id":"","url":"https://api.github.com/users/cmdcolin","html_url":"https://github.com/cmdcolin","followers_url":"https://api.github.com/users/cmdcolin/followers","following_url":"https://api.github.com/users/cmdcolin/following{/other_user}","gists_url":"https://api.github.com/users/cmdcolin/gists{/gist_id}","starred_url":"https://api.github.com/users/cmdcolin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmdcolin/subscriptions","organizations_url":"https://api.github.com/users/cmdcolin/orgs","repos_url":"https://api.github.com/users/cmdcolin/repos","events_url":"https://api.github.com/users/cmdcolin/events{/privacy}","received_events_url":"https://api.github.com/users/cmdcolin/received_events","type":"User","site_admin":false},"created_at":"2015-11-11T00:08:49Z","updated_at":"2015-11-11T00:08:49Z","body":"I know this is just a documentation issue but I don't think the update doc in 630e691 is accurate\r\n\r\n\r\n@erasche has the orgiinal comment \"I take this to mean that the controller never expected to receive a JSON object and I'm not 100% sure how it actually functions as such.\"\r\n\r\nThis is true, the addOrganism API does not expect a json object for the organism, just a like of json parameters for each part of the organism\r\n\r\n\r\ni.e. I would call the API like this\r\n\r\n\r\n    curl -H \"Content-Type: application/json\" -X POST -d '{\"username\":\"me\",\"password\":\"pass\",\"directory\":\"/opt/apollo/pyu_data\",\"commonName\":\"orgname\",\"publicMode\":true}' http://localhost:8080/apollo/organism/addOrganism\r\n\r\n\r\nand not\r\n\r\n    curl -H \"Content-Type: application/json\" -X POST -d '{\"username\":\"me\",\"password\":\"pass\",\"organism\":{\"directory\":\"/opt/apollo/pyu_data\",\"commonName\":\"orgname\",\"publicMode\":true}}' http://localhost:8080/apollo/organism/addOrganism\r\n"}}