{"action":"created","issue":{"url":"https://api.github.com/repos/netbeast/dashboard/issues/40","repository_url":"https://api.github.com/repos/netbeast/dashboard","labels_url":"https://api.github.com/repos/netbeast/dashboard/issues/40/labels{/name}","comments_url":"https://api.github.com/repos/netbeast/dashboard/issues/40/comments","events_url":"https://api.github.com/repos/netbeast/dashboard/issues/40/events","html_url":"https://github.com/netbeast/dashboard/issues/40","id":135687322,"number":40,"title":"Error using superagent with form-data","user":{"login":"cayrodmed1","id":16781072,"avatar_url":"https://avatars.githubusercontent.com/u/16781072?v=3","gravatar_id":"","url":"https://api.github.com/users/cayrodmed1","html_url":"https://github.com/cayrodmed1","followers_url":"https://api.github.com/users/cayrodmed1/followers","following_url":"https://api.github.com/users/cayrodmed1/following{/other_user}","gists_url":"https://api.github.com/users/cayrodmed1/gists{/gist_id}","starred_url":"https://api.github.com/users/cayrodmed1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cayrodmed1/subscriptions","organizations_url":"https://api.github.com/users/cayrodmed1/orgs","repos_url":"https://api.github.com/users/cayrodmed1/repos","events_url":"https://api.github.com/users/cayrodmed1/events{/privacy}","received_events_url":"https://api.github.com/users/cayrodmed1/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/netbeast/dashboard/labels/help%20wanted","name":"help wanted","color":"159818"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-02-23T09:46:50Z","updated_at":"2016-02-24T12:48:34Z","closed_at":null,"body":"When trying to use `superagent` instead of `request` in tests, I'm getting an error with 2 tests. This tests both use form-data. In `request` it is like:\r\n```\r\nvar request = require('request')\r\nvar req = request.post(URL + '/apps', function (err, resp, body) {\r\n     // Test code\r\n    })\r\nvar form = req.form()\r\nvar app = path.join(__dirname, '../app.tar.gz')\r\nform.append('file', fs.createReadStream(app))\r\n```\r\nI've found out that `attach` is the equivalent for `append` in `superagent`, so with `superagent` it would be:\r\n```\r\nvar agent = require('superagent')\r\nvar app = path.join(__dirname, '../app.tar.gz')\r\nagent.post(URL + '/apps')\r\n    .attach('file', fs.createReadStream(app))\r\n    .end(function (err, resp, body) {\r\n     // Test code\r\n    })\r\n```\r\nI execute this code and dashboard throws the following error: \r\n\r\n> Error: App must be a .tar.gz file.\r\n\r\nAnd this throws the 422 error (Unprocessable Entity) in tests.\r\n\r\nIt seems like it doesn't take the route to the app properly, but I don't know why it happens.\r\n\r\nAny idea? Am I doing something wrong?"},"comment":{"url":"https://api.github.com/repos/netbeast/dashboard/issues/comments/188240191","html_url":"https://github.com/netbeast/dashboard/issues/40#issuecomment-188240191","issue_url":"https://api.github.com/repos/netbeast/dashboard/issues/40","id":188240191,"user":{"login":"cayrodmed1","id":16781072,"avatar_url":"https://avatars.githubusercontent.com/u/16781072?v=3","gravatar_id":"","url":"https://api.github.com/users/cayrodmed1","html_url":"https://github.com/cayrodmed1","followers_url":"https://api.github.com/users/cayrodmed1/followers","following_url":"https://api.github.com/users/cayrodmed1/following{/other_user}","gists_url":"https://api.github.com/users/cayrodmed1/gists{/gist_id}","starred_url":"https://api.github.com/users/cayrodmed1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cayrodmed1/subscriptions","organizations_url":"https://api.github.com/users/cayrodmed1/orgs","repos_url":"https://api.github.com/users/cayrodmed1/repos","events_url":"https://api.github.com/users/cayrodmed1/events{/privacy}","received_events_url":"https://api.github.com/users/cayrodmed1/received_events","type":"User","site_admin":false},"created_at":"2016-02-24T12:48:34Z","updated_at":"2016-02-24T12:48:34Z","body":"Yes, I'm doing it like this. This is the full code:\r\n```\r\nvar agent = require('superagent')\r\nvar app = path.join(__dirname, '../app.tar.gz')\r\nagent.post(URL + '/apps')\r\n    .set('Content-Type', 'application/octet-stream')\r\n    .attach('file', fs.createReadStream(app))\r\n    .end(function (err, resp, body) {\r\n     // Test code\r\n    })\r\n```"}}