如何通过API与JSON主体一起在Jmeter中上传PDF文件作为请求,而无需将PDF文件转换为bytecode

发布于 2025-02-01 12:50:08 字数 374 浏览 4 评论 0 原文

有人可以帮助我在使用Jmeter的API请求上上传PDF文件以及JSON主体吗?

JSON Body:- {  
                "name" :"xyz",
                "token" : "123OuvP4"

              }

Pdf file name - PT_001.pdf 

API URL - apiq-bbmma-stq.azure-api.net/DocMqmt/UploadDocument

Header Manager : - Content-Type:- multipart/related; Boundary:-"Aa0b12x"

请指导我如何执行此操作,而无需将PDF文件转换为字节码

can someone please help me to upload a pdf file along with JSON body as a request through API using JMeter?

JSON Body:- {  
                "name" :"xyz",
                "token" : "123OuvP4"

              }

Pdf file name - PT_001.pdf 

API URL - apiq-bbmma-stq.azure-api.net/DocMqmt/UploadDocument

Header Manager : - Content-Type:- multipart/related; Boundary:-"Aa0b12x"

please guide me on how to do that without converting the pdf file into bytecode

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

岁吢 2025-02-08 12:50:08

我没有得到您的要求。您应该在Multipart请求的单独的“部分”中发送PDF文件。

multipart content-type

--Aa0b12x
Content-Type: application/json; charset=UTF-8

{
  "name": "xyz",
  "token": "123OuvP4"
}
--Aa0b12x
Content-Type: application/pdf

your-pdf-file-content-here, it may be either "raw" or i.e. Base64-encoded
--Aa0b12x--

如果 构建请求手动尝试使用 http请求 sampler and 。更多信息:带有jmeter的记录文件上传

I'm not getting your requirement. You should be sending the PDF file "as it is" in a separate "part" of the multipart request.

In case of Multipart Content-Type you need to send the message like:

--Aa0b12x
Content-Type: application/json; charset=UTF-8

{
  "name": "xyz",
  "token": "123OuvP4"
}
--Aa0b12x
Content-Type: application/pdf

your-pdf-file-content-here, it may be either "raw" or i.e. Base64-encoded
--Aa0b12x--

If you cannot build the request manually try just recording it using HTTP(S) Test Script Recorder, just make sure to copy the PDF file to JMeter's "bin" folder before uploading, this way JMeter will capture the request and generate proper HTTP Request sampler and HTTP Header Manager. More information: Recording File Uploads with JMeter

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文