0

Hi All I want to POST the below format as input in ROBOT Framework.

{
    "Description": "School",
    "Details": [
    {
      "name": "Test1",
      "Surname": "XYZ"
    },
    {
      "name1": "Test2",
      "Surname2": "ABC"
    }
    ]
}

But I am getting the below error

body={"Error":"module 'jsonschema._utils' has no attribute 'types_msg'"}

Below is my code for the same

${tag_1} =  create dictionary        name="Test1"     value"XYZ"
      ${tag_2} =  create dictionary        name="Test2"     value"ABC"
      ${body} =  create list        Description="School"      Details=[$tag_1,$tag_2]
      ${header}=  create dictionary   Authorization=%{TEMP_TOKEN}   content-Type=application/json
     ${create_student}=  post On Session  ABCDE    /input   json=${body}     headers=${header}       expected_status=200
2
  • You do not need quotes around strings. name=Test1 is enough and your quotes might cause issues later. Commented Oct 7, 2021 at 12:48
  • What is value"XYZ"? it is not valid as a dictionary key/value pair and doesn't match your json Commented Oct 7, 2021 at 18:25

1 Answer 1

1

It looks to me like there are a few issues - Mainly, you're trying to store the json in an array, not an object and you're not converting to JSON.

There was also the double quotes around the key values and invalid key/value for value"XYX" and value"ABC" which also doesn't match your example as it should be "Surname"

Some example changes below:

# Name and Surname Objects - Updated to remove double quotes and match the provided json with "Surname" instead of "value"
${tag_1}  Create Dictionary  name=Test1  Surname=XYZ
${tag_2}  Create Dictionary  name=Test2  Surname=ABC

# Details List / Json Array
@{details}  Create List  ${tag_1}  ${tag_2}

# Body - Fixed so it's an object not an array
&{body}  Create Dictionary  
...      Description=School
...      Details=${details}

# Convert the body to JSON
${body}  Evaluate  json.dumps(${body})  json

Output:

{"Description": "School", "Details": [{"name": "Test1", "Surname": "XYZ"}, {"name": "Test2", "Surname": "ABC"}]}
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.