无法执行获取请求。收到400错误的请求错误

时间:2019-12-27 11:34:29

标签: robotframework web-api-testing

这是我的代码

**Settings**
Library    OperatingSystem
Library    RequestsLibrary
Library    Collections
Library    JSONLibrary    
Library    JsonValidator 
**Variables**

${Base_URL}  http://192.168.0.000:8000 (Example) 
${json_path}  C:/LogAPI.json (Example) 
${req}  /v1/api/logs (Example)

*** Test Cases ***
APITesting   
      Create Session    Get_JobId    ${Base_URL}
  ${json}=  Catenate  { "time_zone": "Asia/Calcutta"} 
  Log To Console    ${json}    
  &{headers}  Create Dictionary  Content-Type=application/json; charset=utf-8
  ${Response}=  Get Request     Get_JobId   ${req}    data=${json}  headers=${headers}
  ${code}=  Log To Console    ${Response.status_code}     
  Log To Console    ${Response.content}    
  Should Be Equal    ${code}    200  

这是我的错误

==============================================================================
APITesting                                                            {"time_zone": "Asia/Calcutta"}
400
400 Bad Request
| FAIL |
None != 200
------------------------------------------------------------------------------
Test1.Get-Logs                                                        | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
==============================================================================

0 个答案:

没有答案