This thread is trying to answer question "How to get the default headers defined in the API Request Context before the call for debugging purposes in Playwright?"
Is there any way to get the request headers post call? Sort of like a curl -v
perhaps?
We've run into a situation where the response headers seem to indicate that the apiContext
is calling the UI instead of the API URL. Would like to debug which URL is actually being called.
I've tried using the response.url()
- Is this reporting the requested URL?
See the sample request and response below.
// assuming
// ui url: https://my.ui.url/ui <-- set as baseURL in playwright.config.ts
// api endpoint: https://my.api.url/api/test
const apiContext: APIRequestContext = playwright.request.newContext({
baseURL: 'https://my.api.url/'
});
const response = await apiContext.get('/api/test');
console.log(response.url()) // gives https://my.ui.url/ui
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].