{"action":"created","issue":{"url":"https://api.github.com/repos/postmanlabs/newman/issues/1825","repository_url":"https://api.github.com/repos/postmanlabs/newman","labels_url":"https://api.github.com/repos/postmanlabs/newman/issues/1825/labels{/name}","comments_url":"https://api.github.com/repos/postmanlabs/newman/issues/1825/comments","events_url":"https://api.github.com/repos/postmanlabs/newman/issues/1825/events","html_url":"https://github.com/postmanlabs/newman/issues/1825","id":391700434,"node_id":"MDU6SXNzdWUzOTE3MDA0MzQ=","number":1825,"title":"The environment variable set in sendRequest (prerequest script) during Newman execution not accessible in testscript. Works in Collection Runner and Postman.","user":{"login":"slavenantic","id":43333711,"node_id":"MDQ6VXNlcjQzMzMzNzEx","avatar_url":"https://avatars0.githubusercontent.com/u/43333711?v=4","gravatar_id":"","url":"https://api.github.com/users/slavenantic","html_url":"https://github.com/slavenantic","followers_url":"https://api.github.com/users/slavenantic/followers","following_url":"https://api.github.com/users/slavenantic/following{/other_user}","gists_url":"https://api.github.com/users/slavenantic/gists{/gist_id}","starred_url":"https://api.github.com/users/slavenantic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slavenantic/subscriptions","organizations_url":"https://api.github.com/users/slavenantic/orgs","repos_url":"https://api.github.com/users/slavenantic/repos","events_url":"https://api.github.com/users/slavenantic/events{/privacy}","received_events_url":"https://api.github.com/users/slavenantic/received_events","type":"User","site_admin":false},"labels":[{"id":84268811,"node_id":"MDU6TGFiZWw4NDI2ODgxMQ==","url":"https://api.github.com/repos/postmanlabs/newman/labels/question","name":"question","color":"cc317c","default":true}],"state":"open","locked":false,"assignee":{"login":"codenirvana","id":4865836,"node_id":"MDQ6VXNlcjQ4NjU4MzY=","avatar_url":"https://avatars2.githubusercontent.com/u/4865836?v=4","gravatar_id":"","url":"https://api.github.com/users/codenirvana","html_url":"https://github.com/codenirvana","followers_url":"https://api.github.com/users/codenirvana/followers","following_url":"https://api.github.com/users/codenirvana/following{/other_user}","gists_url":"https://api.github.com/users/codenirvana/gists{/gist_id}","starred_url":"https://api.github.com/users/codenirvana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codenirvana/subscriptions","organizations_url":"https://api.github.com/users/codenirvana/orgs","repos_url":"https://api.github.com/users/codenirvana/repos","events_url":"https://api.github.com/users/codenirvana/events{/privacy}","received_events_url":"https://api.github.com/users/codenirvana/received_events","type":"User","site_admin":false},"assignees":[{"login":"codenirvana","id":4865836,"node_id":"MDQ6VXNlcjQ4NjU4MzY=","avatar_url":"https://avatars2.githubusercontent.com/u/4865836?v=4","gravatar_id":"","url":"https://api.github.com/users/codenirvana","html_url":"https://github.com/codenirvana","followers_url":"https://api.github.com/users/codenirvana/followers","following_url":"https://api.github.com/users/codenirvana/following{/other_user}","gists_url":"https://api.github.com/users/codenirvana/gists{/gist_id}","starred_url":"https://api.github.com/users/codenirvana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codenirvana/subscriptions","organizations_url":"https://api.github.com/users/codenirvana/orgs","repos_url":"https://api.github.com/users/codenirvana/repos","events_url":"https://api.github.com/users/codenirvana/events{/privacy}","received_events_url":"https://api.github.com/users/codenirvana/received_events","type":"User","site_admin":false}],"milestone":null,"comments":1,"created_at":"2018-12-17T12:57:04Z","updated_at":"2018-12-18T14:44:22Z","closed_at":null,"author_association":"NONE","body":"<!--\r\nWelcome to the Newman Issue tracker. Any feature requests / bug reports can be posted here.\r\nAny security-related bugs should be reported directly to security@getpostman.com\r\n\r\nThis issue reporting template should guide you to effectively report issues for fastest resolution. Please provide all relevant details in the list below.\r\n\r\nVersion and environment information:\r\n-->\r\n 1. Newman Version (can be found via `newman -v`): 4.2.2\r\n 2. OS details (type, version, and architecture): Windows 10 Pro, 64\r\n 3. Are you using Newman as a library, or via the CLI? CLI\r\n 3. Did you encounter this recently, or has this bug always been there: Recently\r\n 4. Expected behaviour: To update the environment variable inside the sendRequest in the same manner as from Collection Runner and Postman\r\n 5. Command / script used to run Newman: (pre-request script)\r\n`// \r\nlet id1 = 19;\r\nlet isDataDriven = pm.iterationData.get(\"Input\");\r\nlet id2 = 0;\r\n\r\nif (isDataDriven) {\r\n    id1 = pm.iterationData.get(\"Input\").id1;\r\n    id2 = pm.iterationData.get(\"Input\").id2;\r\n    pm.environment.set('id2', id2);\r\n}\r\n\r\nvar requestUrl = pm.environment.get(\"environment\") + '/resource/' + id1;\r\nvar options = { method: 'GET', url: requestUrl };\r\n\r\npm.sendRequest(options, function (error, response) {\r\n    if (error) throw new Error(error);\r\n    var jsonData = response.json();\r\n    pm.environment.set('responseTime', response.responseTime);\r\n    if (id2 !== 0) {\r\n        id2 = jsonData.id2;\r\n        pm.environment.set('id2', id2);\r\n    }\r\n});`\r\n 6. Sample collection, and auxiliary files (minus the sensitive details):\r\n 7. Screenshots (if applicable):\r\n\r\n<!--\r\nSteps to reproduce the problem:\r\n\r\n1. Run the collection from postman and the \"responseTime\" variable exists in Postman and Collection runner. In \"test script\" I am getting the environment variable responseTime and check the value.\r\n2. Run the collection from newman, the variable does not exist \"undefined\" is given.\r\n-->\r\n\r\n\r\n<!--\r\nBefore proceeding, please consider the following:\r\n\r\n1. If this is a Postman Client App issue, go to https://github.com/postmanlabs/postman-app-support/issues/new\r\n\r\n2. Report security issues directly to security@getpostman.com. Please refrain from publicly disclosing any details about security issues in any form, until a fix has been rolled out.\r\n\r\n3. For Postman Cloud / personal information related issues, send an email to: [help@getpostman.com](mailto:help@getpostman.com)\r\n\r\n4. Verify that you have checked the documentation at https://www.getpostman.com/docs/newman_intro, and searched through previously closed issues.\r\n\r\n5. Please ensure that all supporting files (collections or screenshots) do not contain any sensitive information.\r\n-->\r\n"},"comment":{"url":"https://api.github.com/repos/postmanlabs/newman/issues/comments/448243950","html_url":"https://github.com/postmanlabs/newman/issues/1825#issuecomment-448243950","issue_url":"https://api.github.com/repos/postmanlabs/newman/issues/1825","id":448243950,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0ODI0Mzk1MA==","user":{"login":"slavenantic","id":43333711,"node_id":"MDQ6VXNlcjQzMzMzNzEx","avatar_url":"https://avatars0.githubusercontent.com/u/43333711?v=4","gravatar_id":"","url":"https://api.github.com/users/slavenantic","html_url":"https://github.com/slavenantic","followers_url":"https://api.github.com/users/slavenantic/followers","following_url":"https://api.github.com/users/slavenantic/following{/other_user}","gists_url":"https://api.github.com/users/slavenantic/gists{/gist_id}","starred_url":"https://api.github.com/users/slavenantic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slavenantic/subscriptions","organizations_url":"https://api.github.com/users/slavenantic/orgs","repos_url":"https://api.github.com/users/slavenantic/repos","events_url":"https://api.github.com/users/slavenantic/events{/privacy}","received_events_url":"https://api.github.com/users/slavenantic/received_events","type":"User","site_admin":false},"created_at":"2018-12-18T14:44:22Z","updated_at":"2018-12-18T14:44:22Z","author_association":"NONE","body":"Is there any chance to send these things to you via email?"}}
{"actor":{"display_login":"slavenantic"}}