{"action":"opened","issue":{"url":"https://api.github.com/repos/shoreditch-ops/artillery-core/issues/187","repository_url":"https://api.github.com/repos/shoreditch-ops/artillery-core","labels_url":"https://api.github.com/repos/shoreditch-ops/artillery-core/issues/187/labels{/name}","comments_url":"https://api.github.com/repos/shoreditch-ops/artillery-core/issues/187/comments","events_url":"https://api.github.com/repos/shoreditch-ops/artillery-core/issues/187/events","html_url":"https://github.com/shoreditch-ops/artillery-core/issues/187","id":247018566,"number":187,"title":"beforeReqeust's requestParams can't be customized.","user":{"login":"outsideris","id":390146,"avatar_url":"https://avatars1.githubusercontent.com/u/390146?v=4","gravatar_id":"","url":"https://api.github.com/users/outsideris","html_url":"https://github.com/outsideris","followers_url":"https://api.github.com/users/outsideris/followers","following_url":"https://api.github.com/users/outsideris/following{/other_user}","gists_url":"https://api.github.com/users/outsideris/gists{/gist_id}","starred_url":"https://api.github.com/users/outsideris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/outsideris/subscriptions","organizations_url":"https://api.github.com/users/outsideris/orgs","repos_url":"https://api.github.com/users/outsideris/repos","events_url":"https://api.github.com/users/outsideris/events{/privacy}","received_events_url":"https://api.github.com/users/outsideris/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-08-01T10:05:04Z","updated_at":"2017-08-01T10:05:04Z","closed_at":null,"body":"```\r\n- post:\r\n    url: '/login'\r\n    beforeRequest: 'setDeviceAsJson'\r\n    json:\r\n      grant_type: 'password'\r\n      email: '{{ username }}'\r\n      password: '{{ password }}'\r\n      device: '{{ device }}'\r\n```\r\n\r\nIn here, `device` is JSON, but the request stringifies it. So, I want to customize `device` in `beforeRequest` hook.\r\n\r\nAs the [document](https://artillery.io/docs/testing_http.html#http-specific-configuration), `requestParams` object is for it.\r\n\r\n> requestParams is an object given to the Request library. Use this parameter to customize what is sent in the request (headers, body, cookies etc)\r\n\r\n```\r\n// process.js\r\nmodule.exports = {\r\n  setDeviceAsJson: (requestParams, context, ee, next) => {\r\n    requestParams.json.device = JSON.parse(context.vars.device);\r\n    return next();\r\n  },\r\n};\r\n```\r\n\r\nHowever, reqeust's json wasn't changed, even if `requestParams` was changed.\r\n\r\nIn [here](https://github.com/shoreditch-ops/artillery-core/blob/master/lib/engine_http.js#L202), `requestParams` is overwritten after running `beforeRequest` hook. This change was introduced in [this commit](https://github.com/shoreditch-ops/artillery-core/commit/405b78ec534b7c484555eeadfffdb5db0e87654c), but I can't understand what your intention is.\r\n\r\n`requestParams` looks useless in the hook."}}
{"actor":{"display_login":"outsideris"}}