{"action":"created","issue":{"url":"https://api.github.com/repos/request/request/issues/1424","labels_url":"https://api.github.com/repos/request/request/issues/1424/labels{/name}","comments_url":"https://api.github.com/repos/request/request/issues/1424/comments","events_url":"https://api.github.com/repos/request/request/issues/1424/events","html_url":"https://github.com/request/request/issues/1424","id":57445910,"number":1424,"title":"Some multipart requests are invalid","user":{"login":"sparkyfied","id":1658734,"avatar_url":"https://avatars.githubusercontent.com/u/1658734?v=3","gravatar_id":"","url":"https://api.github.com/users/sparkyfied","html_url":"https://github.com/sparkyfied","followers_url":"https://api.github.com/users/sparkyfied/followers","following_url":"https://api.github.com/users/sparkyfied/following{/other_user}","gists_url":"https://api.github.com/users/sparkyfied/gists{/gist_id}","starred_url":"https://api.github.com/users/sparkyfied/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sparkyfied/subscriptions","organizations_url":"https://api.github.com/users/sparkyfied/orgs","repos_url":"https://api.github.com/users/sparkyfied/repos","events_url":"https://api.github.com/users/sparkyfied/events{/privacy}","received_events_url":"https://api.github.com/users/sparkyfied/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-12T11:03:40Z","updated_at":"2015-02-12T12:18:56Z","closed_at":"2015-02-12T12:18:56Z","body":"When attempting to run the following code, I get a 400 Bad Request error back from the Google API.\r\n```javascript\r\nrequest.post({\r\n\t'uri': 'https://www.googleapis.com/batch',\r\n\t'auth': {\r\n\t\t'bearer': 'Bearer ...auth code...'\r\n\t},\r\n\t'headers': {\r\n\t\t'Content-Type': 'multipart/mixed;'\r\n\t},\r\n\tmultipart: [\r\n\t\t{\r\n\t\t\t'content-type': 'application/json',\r\n\t\t\tbody: 'GET /plusDomains/v1/people/me/activities/user'\r\n\t\t},\r\n\t\t{\r\n\t\t\t'content-type': 'application/json',\r\n\t\t\tbody: 'GET /plusDomains/v1/people/me/circles'\r\n\t\t}\r\n\t]\r\n});\r\n```\r\n\r\nI've been able to successfully run the same request by manually setting the boundary and then manually writing each part of the request: \r\n```javascript\r\nrequest.post({\r\n\t...\r\n\t'headers': {\r\n        'Content-Type': 'multipart/mixed; boundary=' + boundary\r\n    },\r\n    ...\r\n}).write('\\r\\n--' + boundary + '\\r\\nContent-Type: application/http\\r\\n\\r\\nGET /plusDomains/v1/people/me/activities/user\\r\\n\\r\\n\\r\\n--' + boundary + '\\r\\nContent-Type: application/http\\r\\n\\r\\nGET /plusDomains/v1/people/me/circles\\r\\n\\r\\n--' + boundary + '--'));\r\n```\r\n\r\nWhen using the `multipart` option the request fails. I've looked into this and can see that the request is in fact invalid:\r\n```javascript\r\nheaders: \r\n   { 'content-type': 'multipart/mixed; boundary=af62abce-cef0-4805-9d24-c44ae1dd663c',\r\n     host: 'www.googleapis.com',\r\n     authorization: 'Bearer ...auth code...',\r\n     'content-length': 274 },\r\n  body: '--af62abce-cef0-4805-9d24-c44ae1dd663c\\r\\ncontent-type: application/http\\r\\n\\r\\n,GET /plusDomains/v1/people/me/activities/user,\\r\\n,--af62abce-cef0-4805-9d24-c44ae1dd663c\\r\\ncontent-type: application/http\\r\\n\\r\\n,GET /plusDomains/v1/people/me/circles,\\r\\n,--af62abce-cef0-4805-9d24-c44ae1dd663c--' }\r\n```\r\n\r\nIt seems to me that the body of the request is invalid as commas are added:\r\n```raw\r\n--af62abce-cef0-4805-9d24-c44ae1dd663c\r\ncontent-type: application/http\r\n\r\n,GET /plusDomains/v1/people/me/activities/user,\r\n,--af62abce-cef0-4805-9d24-c44ae1dd663c\r\ncontent-type: application/http\r\n\r\n,GET /plusDomains/v1/people/me/circles,\r\n,--af62abce-cef0-4805-9d24-c44ae1dd663c--\r\n```\r\n\r\nIs this a bug? Or am I missing something?\r\n"},"comment":{"url":"https://api.github.com/repos/request/request/issues/comments/74062032","html_url":"https://github.com/request/request/issues/1424#issuecomment-74062032","issue_url":"https://api.github.com/repos/request/request/issues/1424","id":74062032,"user":{"login":"sparkyfied","id":1658734,"avatar_url":"https://avatars.githubusercontent.com/u/1658734?v=3","gravatar_id":"","url":"https://api.github.com/users/sparkyfied","html_url":"https://github.com/sparkyfied","followers_url":"https://api.github.com/users/sparkyfied/followers","following_url":"https://api.github.com/users/sparkyfied/following{/other_user}","gists_url":"https://api.github.com/users/sparkyfied/gists{/gist_id}","starred_url":"https://api.github.com/users/sparkyfied/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sparkyfied/subscriptions","organizations_url":"https://api.github.com/users/sparkyfied/orgs","repos_url":"https://api.github.com/users/sparkyfied/repos","events_url":"https://api.github.com/users/sparkyfied/events{/privacy}","received_events_url":"https://api.github.com/users/sparkyfied/received_events","type":"User","site_admin":false},"created_at":"2015-02-12T12:18:56Z","updated_at":"2015-02-12T12:18:56Z","body":"@simov Wow, so simple, thanks!"}}