I am trying to use AWS API and its API-key in POST/PUT call in Cypress, couldn't find enough details, can someone please help?
I am trying to use AWS API and its API-key in POST/PUT call in Cypress, couldn't find enough details, can someone please help?
There are few options you can try, Here is one :
cy.intercept('POST', '/users*', (req) => {
req.headers['x-api-key'] = 'bearer my-bearer-auth-token'
}).as('addAuthHeader')
Refer Offical Link here: https://docs.cypress.io/guides/guides/network-requests#Assertions
You can use cy.request. Although not outlined in the docs, it accepts an object:
cy.request({
method: 'POST',
url: 'https://jsonplaceholder.cypress.io/',
headers: { 'x-api-key': 'APIKEY' },
}).then((res) => {
// use the response with response.body
});