新手:我正在尝试从 POST 调用的响应正文中获取 id。 POST 成功,但当我尝试获取 id 并记录它时,它返回 null。我想我只是错过了一件小事,但是是的,需要你的帮助。
${response_body} Decode Bytes To String ${response.content} encoding=utf-8
Set Test Variable ${response_body}
Log ${response_body}
${id} Get Value From Json ${response_body} id
Log ${id}
实际响应正文只是:
{
"id": "546e0c4d-b810-49e6-a674-0d0f812bb790"
}
以下是我在报告中得到的内容:
没有错误,只有空白值
我尝试将response_body设置为整体id,但当我调用${id}时,我得到“id”=“xxxxx ...”,所以是的,我只需要该值
你的问题是
${response_body}
是一个字符串,而不是一个 JSON。您必须使用“Convert String To Jsonto convert it to JSON before
Get Value From Json”有效。