-
Notifications
You must be signed in to change notification settings - Fork 227
Open
Labels
featureNew feature request, accepted for probable developmentNew feature request, accepted for probable development
Description
How can I include a Collection Pre-Request Script?
I have a Collection Pre-Request Script that will setup a header for all requests made by my collection, but I can't find how to add this script into OpenAPI format to be converted correctly? OR is there a way the package can insert this script instead of adding it in OpenAPI?
Here's the script I'm wanting to include after running openapi-to-postmanv2:
pm.request.headers.add({key: 'X-Project-Client', value: "{{X-Project-Client}}" })
When I manually add this to my collection and export it, it will appear like this in the export json (edited for brevity):
{
"info": {
"_postman_id": "12345",
"name": "Collection Name",
"description": "My collection description",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [...]
"event": [
{
"listen": "prerequest",
"script": {
"id": "12234",
"type": "text/javascript",
"exec": [
"pm.request.headers.add({key: 'X-Project-Client', value: \"{{X-Project-Client}}\" })"
]
}
},
{
"listen": "test",
"script": {
"id": "1234",
"type": "text/javascript",
"exec": [
""
]
}
}
],
"variable": [...],
}
ANorwell, rohit-gohri, nhammond101, sn0rk64 and kevinboostensn0rk64sn0rk64sn0rk64sn0rk64
Metadata
Metadata
Assignees
Labels
featureNew feature request, accepted for probable developmentNew feature request, accepted for probable development