【问题标题】:uploading a .yml file to graphql in jmeter在 jmeter 中将 .yml 文件上传到 graphql
【发布时间】:2021-04-07 13:01:43
【问题描述】:

我正在尝试通过 post 方法将 yml 文件上传到 graphql 端点,并在 JMeter 中收到以下错误,

错误详情:

http状态码:400

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>BadRequestError: Missing multipart field ‘operations’ (https://github.com/jaydenseric/graphql-multipart-request-spec).<br> &nbsp; &nbsp;at Busboy.&lt;anonymous&gt; (/app/node_modules/graphql-upload/public/processRequest.js:329:11)<br> &nbsp; &nbsp;at Object.onceWrapper (events.js:421:28)<br> &nbsp; &nbsp;at Busboy.emit (events.js:327:22)<br> &nbsp; &nbsp;at Busboy.emit (/app/node_modules/busboy/lib/main.js:37:33)<br> &nbsp; &nbsp;at /app/node_modules/busboy/lib/types/multipart.js:304:17<br> &nbsp; &nbsp;at processTicksAndRejections (internal/process/task_queues.js:75:11)</pre>
</body>
</html>

在正文部分请求有效负载详细信息:

------file_upload_for_schema
Content-Disposition: form-data; name="operations"

{"operationName":"fSchemaCreate","variables":{"record":{"name":"jam_test","file":null}},"query":"mutation fSchemaCreate($record: CreateOnefSchemaInput!) {\n  fSchemaCreate(record: $record) {\n    recordId\n    __typename\n  }\n}\n"}
------file_upload_for_schema
Content-Disposition: form-data; name="map"
{"1":["variables.record.file"]}
------file_upload_for_schema
Content-Disposition: form-data; name="1"; filename="conferenceImage.yml"
Content-Type: application/x-yaml
------file_upload_for_schema--

请求头配置:

我的应用程序的实际 UI 屏幕:

从浏览器捕获:

编辑后我仍然面临这个问题;

【问题讨论】:

    标签: jmeter


    【解决方案1】:

    我认为您需要从“身体数据”中删除所有内容并像这样配置HTTP Request 采样器:

    一般来说,如果文件上传在浏览器中工作,您可以使用 JMeter 的HTTP(S) Test Script Recorder 简单地记录相关请求,只需确保将您要上传的文件复制到“bin”文件夹您的 JMeter 安装,这样 JMeter 将能够正确生成 HTTP 请求采样器以及 HTTP Header Manager(s)

    更多信息:Recording File Uploads with JMeter

    【讨论】:

    • 谢谢 Dimitri 的建议,我应该保持原样上传文件吗?
    • 我不确定 mime 类型,很可能应该是 text/yamlapplication/x-yaml
    • Dmitri,如何从请求负载中删除此字符集、内容传输和内容类型
    【解决方案2】:

    只是添加到 Dimitri 的配置,请从标头管理器中删除 Content-Type

    【讨论】:

    • 非常感谢 Jyoti,这在我从标头管理器中删除 Content-Type 后有效。
    猜你喜欢
    • 1970-01-01
    • 2021-11-01
    • 2021-10-19
    • 2016-08-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-11
    • 2020-12-04
    相关资源
    最近更新 更多