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
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"}]}