0

Here is my code. I am getting error for this. Can anyone help

*** Settings ***

Library    RequestsLibrary
Library    JSONLibrary
Library    Collections

*** Variables ***
${base_url}     https://reqres.in
@{header}       Content-Type=application/json; charset=utf-8

*** Test Cases ***
POST_userInfo
    Create Session    mysession     ${base_url}
    ${body}=    Create Dictionary   name=Prad    job=leader

    ${response}=   POST On Session         mysession      api/users   data= ${body}   headers=@{header}
    Log To Console    ${response.status_code}
    Log To Console     ${response.content}
    Should Be Equal As Strings       ${response.status_code}  201



I am expecting POST request to sucess

1
  • I changed it but still see same issue Commented Dec 22, 2022 at 22:21

1 Answer 1

1

The passed headers are expected to be a dictionary, while you are creating and passing a list object; hence the error, though a bit obscure (being a python one), it says literally that.

If you want to define them in the Setting section, switch to this format:

&{header}       Content-Type=application/json    charset=utf-8

Note the prefix before the variable's name (ampersand), and how the key=value pairs are separated with 2 or more spaces between them.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.