Cypress how to use api key in put/post request?

Viewed 453

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?

3 Answers

I was able to resovle it syntax is: authorization : key + value no quotes –

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
});
Related