Post-Processor sendRequest header isn't working


Hello, please try adding quotes around the header parameter name and see if that resolves the issue.

look at the second header

it isn’t sends at actual request headers

The field name is header instead of headers.

thank you so much, Emily

but can You help me

if (pm.response.code === 401) {
    const refresh = pm.environment.get('AUTH_REFRESH')
    console.log(refresh)

    pm.sendRequest({
        url: `${pm.environment.get('BASE_URL')}/auth/refresh`,
        method: 'POST',
        header: {
            'cookie': `refresh=${refresh}`
        },
    }, function (error, response) {
        if (!error && response.code !== 401) {
            console.log(response.json())
            pm.environment.set('AUTH_TOKEN', response.json().data.token);

            const header = response.headers.get('set-cookie');

            const cookies = header.split(';');
            const cookie = cookies[0];

            const [name, value] = cookie.split('=');

            if (name === 'refresh') {
                if (value === '') {
                    pm.environment.set('AUTH_REFRESH', undefined);
                    return;
                }
                pm.environment.set('AUTH_REFRESH', value);
            }
        }
    });
}

can I automatic retry the previous request if refresh is passed successfully?

I’m sorry, the retry function is not supported at the moment.Thanks for the feedback, we will think about how to optimize it.

However, you can refer to the conditional branching and loop components of automated testing, which may be helpful to you.For detailed information, please check here: Flow control conditions - Apidog Docs