无法在Vugen中使用Web http/html捕获JSON响应



步骤功能:创建草稿;通过在服务器响应

中创建草稿id显示的成功状态

调用:

web_custom_request("draft",
        "URL=https://xxx.yyy.com/__services/v2/rest/draft", 
        "Method=POST", 
        "Resource=0", 
        "RecContentType=text/xml", 
        "Referer=https://xxx.yyy.com/blog/create-post.jspa?containerType=14&containerID=1", 
        "Snapshot=t7.inf", 
        "Mode=HTML", 
        "EncType=application/json; charset=utf-8", 
        "Body={"objectType":38,"draftObjectType":2020,"draftObjectID":137742,"subject":"perf test 2","body":"<body><p>test data</p></body>","properties":{"publishBar":{"container":{"objectType":"37","objectID":"90094"},"visibility":"all","commentStatus":"2","blogPublishOption":false,"publishDate":{"selectedDate":"{p_Date}","selectedHour":"1","selectedMinute":"0","selectedPeriod":"AM"}}}}", 
        LAST);

相关数据:draft ID;此呼叫的响应参数化数据:selectedDate其余值为常数

记录响应体:

{
  "id" : 2814,
  "objectType" : 38,
  "draftObjectType" : 2020,
  "draftObjectID" : 137742,
  "subject" : "perf test",
  "body" : "<body><p>this i</p></body>",
  "modificationDate" : "2015-10-12T13:44:00.854+0000",
  "properties" : {
    "publishBar" : {
      "container" : {
        "objectType" : "37",
        "objectID" : "90094"
      },
      "visibility" : "all",
      "commentStatus" : "2",
      "blogPublishOption" : false,
      "publishDate" : {
        "selectedDate" : "10/13/2015",
        "selectedHour" : "1",
        "selectedMinute" : "0",
        "selectedPeriod" : "AM"
      }
    }
  }
}

重放错误:

{ "code" : 500, "message" :com.sun.istack.SAXException2: class java.util.LinkedHashMap nor any of its super class is known to this context.
javax.xml.bind.JAXBException: class java.util.LinkedHashMap nor any of its super class is known to this context." }

请帮助。

很明显,你没有把所有需要关联的东西都关联起来。重新录音,看看每次录音的反应有什么不同。

如果没有完整的脚本,我不能肯定,但至少在您的请求中更改以下内容:

从"RecContentType=text/xml"到"RecContentType=application/json"

"Mode=HTML"到"Mode=HTTP"

第一个设置预期的响应内容类型,如果不是XML,可能会有问题。这是假设服务使用正确的内容类型进行响应。

second将模式设置为HTTP,因为REST API响应通常不需要解析内容。

最新更新