How to solve 401 unauthorized error?

When I send post request and track http,I saw that my “apikey” parameter in headers returns “Apikey” .Because of this I m taking 401 unauthorized. How to solve this problem?

export function CreateEmptyWareHouse(data){
    
    let emptyWareHouseSeedHeader = {
        headers: {
            "Authorization": `Bearer ${data.access_token}`,
            "accept": "*/*",
            "Content-Type":"application/json",
            "apikey":"****"
        },
    };
     
    describe('EmptyWareHouseSeed çalıştırır', (t) => {
        let emptyWareHouseSeedRes = http.post("https://test/dev/v1/Main/Test?test=EmptyWarehouse&operation=Classic&recreateDb=true", JSON.stringify({}), emptyWareHouseSeedHeader)
        t.expect(emptyWareHouseSeedRes.status).toEqual(204);
        sleep(10)
    });
}

@mstoykov do u have an idea?

Hi @Yusuf , please don’t @ me somebody else or me can answer this without proding :wink:

I am pretty sure you are hitting Case-sensitive header APIs are not usable · Issue #1246 · grafana/k6 · GitHub which as noted in the last comment is unlikely to land.

In short your API should not care if it’s headers are upper or lower case and if it does it is not in compliance with the specification.

This is even more strange as HTTP2 specifically makes all header lowercase during transmission. Which is what go(and consequently k6) already does.

I don’t really have a recommendation apart from fix the server implementaiton though :person_shrugging: