由网友(强奸不成反被操)分享简介:我有一个测试套件Library RequestsLibraryLibrary JSONLibraryLibrary OperatingSystem*** Variable ***${base_url} https://api.sportpartnerxxx.vn/v1${identi...![Apache OpenWhisk架构概述](https://p.xsw88.cn/allimgs/daicuo/20230903/1833.png)
我有一个测试套件
Library RequestsLibrary
Library JSONLibrary
Library OperatingSystem
*** Variable ***
${base_url} https://api.sportpartnerxxx.vn/v1
${identity_URL} https://identity.sportpartnerxxx.vn
${Profile} https://api.sportpartnerxxx.vn/v1/profile
*** Test Cases ***
Login
${body}= Create Dictionary client_id=sportpartner-mobile-app client_secret=ifd-sportpartner-secret-2021-mobile-app grant_type=password username=nnbbtd@gmail.com password=123456
${header}= create dictionary content_type=application/x-www-form-urlencoded
${response}= Post ${identity_URL}/connect/token headers=${header} data=${body}
Set Suite Variable ${token} Bearer ${response.json()["access_token"]}
Set Suite Variable ${refresh_token} ${response.json()["refresh_token"]}
Status Should Be 200
Log To Console ${token}
UpdateLanguageStatus
${body}= Create Dictionary languageId=20
${header}= create dictionary Content-Type=application/json Authorization=${token}
${response}= PUT ${Profile}/me/settings data=${body} headers=${header}
Log To Console ${response.status_code}
Log To Console ${response.content}
返回Login Pass,UpdateLanguageStatus失败。UpdateLanguageStatus返回400。我不知道原因。另一方面,我在邮递员上运行这个测试用例,它工作得很好 enter image description here。有人帮我吗?
推荐答案
![Apache OpenWhisk架构概述](https://p.xsw88.cn/allimgs/daicuo/20230903/1833.png)
在发送请求之前,${Body}的词典内容似乎没有序列化为JSON。 输出如下所示:
{'languageId': '20'}
它应该是这样的:
{"languageId": "20"}
您可以在发送前添加以下内容:
${body} Evaluate json.dumps(${body}) json
附加说明-如果languageID为int,则您可能需要更改已有的行,以便20位于${}范围内,例如
${body}= Create Dictionary languageId=${20}
相关推荐
最新文章