Uploading files from scripts is not allowed

I have a request like:

pm.sendRequest({
        url: pm.environment.get("mainUrl") + "/" + pm.environment.get("blackList") + "?name=" + name,
        method: 'POST',
        header: {
            'content-type': 'text/csv',
            'Authorization': "Bearer " + pm.environment.get("accessToken"),
            'Accept': "*/*"
        },
        body: {
            mode: 'formdata',
            formdata: [{
                "key": "file",
                "type": "file",
                "src": "resources/" + file
            }]
        }
    }

However, Iā€™m getting this error:

Uploading files from scripts is not allowed

I need to upload scripts from pre-request since we are making every test independent of each other. Is there any way to achieve this?

1 Like