【问题标题】:How do I send Request Body in Robot Framework如何在机器人框架中发送请求正文
【发布时间】:2022-08-12 05:59:51
【问题描述】:

如何在机器人框架中发送请求正文 发布请求正文,但它给出了客户端错误的问题:“URL 不可接受:https://apiexample.com/demo”

*** Test Cases ***
GenerateToken
    ${headers}=  create dictionary   Content-Type=application/json
    ${body}=  create dictionary    username=abc@example.in   password=abc123 // I can not pass this request body in Post session below
    #${body}=   get file  /Users/Documents/data.json   // This method works but **I don\'t want to use this file method**
    create session  mysession   ${base_Url}     headers=${headers}
    ${response}=    Post On Session    mysession   /demo  data=${body}   headers=${headers}

    标签: api robotframework


    【解决方案1】:

    尝试

    *** Test Cases ***
    
    GenerateToken
        ${headers}=  create dictionary   Content-Type=application/json
        ${body}=  create dictionary    username=abc@example.in   password=abc123
        create session  mysession   ${base_Url}     headers=${headers}
        ${response}=    Post On Session    mysession   /demo  json=${body}   headers=${headers}
    

    【讨论】:

      猜你喜欢
      • 2020-08-07
      • 2019-07-21
      • 1970-01-01
      • 1970-01-01
      • 2020-12-04
      • 2020-04-02
      • 1970-01-01
      • 2014-10-31
      • 2023-03-29
      相关资源
      最近更新 更多