发布请求后,API 将响应正文作为字符串返回
响应体看起来像
{ UniqueID = 93243434,birthGender = M,birthDate = 11/1/2018 5:51:18 PM,familyNames = James,givenNames = Test }
当我尝试使用以下代码设置环境变量时
var data = JSON.parse(responseBody);
postman.setEnvironmentVariable("currentUniqueId", data.UniqueId);
Run Code Online (Sandbox Code Playgroud)
我在测试结果中收到以下错误
错误消息:评估测试脚本时出错:JSONError: Unexpected token 'U' at 1:3 { UniqueID = 93243434,birthGender = M,birthDate = 11/1/2018 5:51:18 PM, family ^
我的目标是我需要提取值 93243434 并分配给环境变量。
postman ×1