ValueError“无法解析为JSON:无法解码JSON对象”

时间:2020-03-26 07:53:09

标签: json

ValueError:无法解析为JSON'...。/:无法解码JSON对象

我遇到了下面提到的代码的错误,我在做什么错,请告诉我 c *设置* 图书馆操作系统 图书馆馆藏 库json 库字符串 库HttpLibrary.HTTP 图书馆要求图书馆 图书馆JSONLibrary 库DataDriver test.xlsx sheet_name = Sheet1

Suite Setup   create the session
Test Template  check_api
Suite Teardown   close session
*** Variables ***
${base_url}   http://10.211.15.228:30181
${result}  Mount point does not exist.
${timeout}  1s
${invalid}  Invalid Parameter
*** Test Cases ***
${TestCase}
*** Keywords ***
create the session
    ${user_pass}=  create list   admin  admin
    create session   mysession   ${base_url}  auth=${user_pass}
check_api
    [Arguments]   ${url}
    ${headers}=  create dictionary  Content-Type=application/json
    ${res}=  get request  mysession  ${url}  headers=${headers}
    sleep  ${timeout}
    ${res1}=  set variable  ${res.status_code}
    ${res2}=  set variable  ${res.content}
    ${res3}=  get json value  ${res2}  /errors/error/0/error-message
    Run Keyword If  '${res1}' == '200'  check_200  ${res2}
    ...    ELSE IF     '${res1}' == '404'  check_404  ${res2}
    ...    ELSE IF     '${res1}' == '500'  check_500  ${res2}
    ...    ELSE  check_404!  ${res1}  ${res2}
check_200
    [Arguments]  ${res2}
    log  200
    log many   ${res2}

check_404
    [Arguments]  ${res2}
    ${res3}=  get json value  ${res2}  /errors/error/0/error-message
    log  404
    log json  ${res2}
    should not be equal   ${res3}  ${result}
check_500
    [Arguments]  ${res2}
    ${res3}=  get json value  ${res2}  /errors/error/0/error-info
    ${res4}=  Get Regexp Matches   ${res3}   message=(\\w+ \\w+)  1
    ${res5}=  set variable  ${res4[0]}
    log  500
    log json  ${res2}
    should be equal  ${res5}  ${invalid}
check_404!
    [Arguments]  ${res1}  ${res2}
    log  ${res1}
    log json  ${res2}
    should be equal  ${res1}  200
close session
    delete all sessions

错误

ValueError:无法解析为JSON:无法解码JSON对象

0 个答案:

没有答案