【问题标题】:Performance Center API to upload scriptPerformance Center API 上传脚本
【发布时间】:2022-02-18 20:02:27
【问题描述】:

我正在开发一个使用 HttpClient 以编程方式将 VuGen 脚本上传到 Performance Center 的 Java 工具。我的工具是:

  1. 验证并保存会话 cookie - /LoadTest/rest/authentication-point/authenticate
  2. 上传脚本 - /LoadTest/rest/domains/[MyDomain]/projects/[MyProject]/Scripts
  3. 注销 - /LoadTest/rest/authentication-point/logout

http://alm-help.saas.hpe.com/en/12.53/api_refs/Performance_Center_REST_API/Performance_Center_REST_API.htm#scripts.htm

身份验证和注销步骤工作正常。即,我可以从身份验证中获取会话 cookie,并在注销时将 cookie 设置为过期。但是,在上传脚本步骤,我总是收到 HTTP 401 错误。这是一条错误消息:

401 - 未经授权:由于凭据无效,访问被拒绝。

您无权使用 您提供的凭据。

这是我发送到 Performance Center 服务器的内容。

POST http://[PC-Host]/LoadTest/rest/domains/[MyDomain]/projects/[MyProject]/Scripts HTTP/1.1
Content-Type: multipart/form-data
Content-Length: 31367
Host: [PC-Server]
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_111)
Cookie: LWSSO_COOKIE_KEY=1y8TbNawvT976BENi4oT1hW6_dCMwcz-eohdFDqWpfIXsW2tUMYHZuHZbUBg9wFQwFnQgfetx5I2EvCfaA5y-g..; QCSession=NjA3NTY5O0JWK0ZjSExzWStwTFZPd2xZSXZ5VlEqKjtQQyBSRVNUIEFQSSBDbGllbnQ7IDsg
Accept-Encoding: gzip,deflate

--_NK2aWTiwhT6VV0TIxkUIaHRx0GhDBZ2LOsY8
Content-Disposition: form-data; name="xml"
Content-Type: application/xml; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

<Script xmlns="http://www.hp.com/PC/REST/API"><TestFolderPath>Subject\DEV\abc</TestFolderPath><Overwrite>true</Overwrite><RuntimeOnly>true</RuntimeOnly><KeepCheckedOut/></Script>
--_NK2aWTiwhT6VV0TIxkUIaHRx0GhDBZ2LOsY8
Content-Disposition: form-data; name="file"; filename="abc.zip"
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary

## binary of zipped vugen script ##
--_NK2aWTiwhT6VV0TIxkUIaHRx0GhDBZ2LOsY8--

我不知道我做错了什么。你有什么想法吗?

【问题讨论】:

    标签: httpclient performance-testing multipart loadrunner


    【解决方案1】:

    问题解决了。 XML 编码是罪魁祸首。 我还转到了请求工具带,以便对多部分结构进行更多控制。

    【讨论】:

    • 你是原创者吗?
    • 很好奇,因为这个保存到性能中心的功能是内置在 VUGEN 中的
    • 不,我不是原始发帖人。我在那里发布了“我也是,但使用 python”评论,然后评论说“xml 编码是罪魁祸首”。但似乎我对答案的线索感到困惑。或者其他的东西。对于那个很抱歉。哦,我现在看到了:“2 天前从评论中删除”。这就解释了为什么评论链没有意义。最好也删除与 XML 相关的注释
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-05-08
    • 1970-01-01
    • 1970-01-01
    • 2019-08-31
    • 1970-01-01
    • 2018-06-01
    • 2018-07-31
    相关资源
    最近更新 更多