POSTMAN请求:
TokenEndPoint - https://api.dev.aa.com//token
Authorization: username: 'fadsfadf353423',
password: 'ZurbhG3kjZ'
Body: grant_type: 'client_credentials'
curl :
curl --location --request POST 'https://api.dev.aa.com/edgemicro-auth/token' \
--header 'Authorization: Basic UkdZZUxSVUpobk5iRkR1QXJ4dzBnV1JNYXY3QmRxS==' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Cookie: _abck=D615B497E043C6F7E72E5F9AB4A34B5E~-1~YAAQDPs7FyzSrg+HAQAAwuC2NwmgIuawZv+zP3GhCafLPgqXpwKMPc9pjZ1IQ1kkIaWLFigGwzSfbIV6Y0cA/octAN264XvJR7IQHlVWNKSW64iR3bKb/4cTCCoKtNVyX3V7O+ekwHo/MhiK2Ie3vzGIw5qXpeqX7VQLSshZ4Tn+YvWCoARgFpSh0H6WhJQqPoKlvl3JJkMogFubx6csEfoHvShZaOdi2E0ddNxQOV2bmSnBtHuN5ntsIskySSqI1NvdXquXIZxyq+ghkDxgCWHaW9uFdLsZChBHZb7MhwSEfXvAeuBC4gSEhg5T8dHltZpYR+DvJQlZPdGh2fccOE8jb07ypbEU+FK5djoEk0qZJypQ6mJyGKqwYnBw6XvdRbBl~-1~-1~1675889701' \
--data-urlencode 'grant_type=client_credentials'
编剧:我试过了:
import { expect, request, test } from "@playwright/test";
const apiUrlEndPoint = 'https://api.dev.aa.com/token'
test('authendPoin', async ({request}) => {
const response = await request.post(apiUrlEndPoint, {
headers: {
//grant_type: 'client_credentials',
grant_type: 'password',
username: 'RGYeLRUJhnNbFDuArxw0gWRMav7BdqJu',
password: 'ZurbhG3kjZviG4xV'
}
//data:processRefundBodyPayload
//data: JSON.stringify(postBody),
})
expect(response.ok()).toBeTruthy
console.log("===================Status Text==============")
console.log(response.statusText())
expect(response.status()).toBe(200)
})
我得到的响应是401而不是200;但是,在POSTMAN中,它按预期状态代码200工作
1条答案
按热度按时间eimct9ow1#
解决方案如下:Playwright配置文件:
剧作家规格文件