如何使用Azure Api Management发送带有文件和数据的后表单数据



我想在Azure API管理上创建一个表单数据格式的发布请求。我必须将文件和正文中的数据发送到url,但不知道如何同时发送。

我从邮递员那里得到http代码:邮递员中的请求

我找不到用文件和数据发送我的帖子请求的方法。当我试图用两个中的一个发送时,我得到了回应:

HTTP/1.1 500 Erreur Interne de Servlet
cache-control: no-cache, no-store, max-age=0, must-revalidate
connection: close
content-language: fr
content-type: text/html;charset=utf-8
date: Thu, 16 Jul 2020 12:21:46 GMT
expires: 0
ocp-apim-trace-location: https://apimstuj2itdypxpozialwwt.blob.core.windows.net/apiinspectorcontainer/UcMgQhu6NisyHHuKEITNDw2-235?sv=2018-03-28&sr=b&sig=Eno9E9bzDcwFOC%2Brl88RY3%2Fq955Ly%2F6r1uyIO0eRwQM%3D&se=2020-07-17T12%3A21%3A45Z&sp=r&traceId=3a143ab6435b46d29e69b30eed34fd23
pragma: no-cache
strict-transport-security: max-age=31536000 ; includeSubDomains
transfer-encoding: chunked
vary: Origin
x-application-context: application
x-content-type-options: nosniff
x-frame-options: DENY
x-xss-protection: 1; mode=block
<!DOCTYPE html><html><head><title>Apache Tomcat/8.0.47 - Rapport d''erreur</title><style type="text/css">H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}.line {height: 1px; background-color: #525D76; border: none;}</style> </head><body><h1>Etat HTTP 500 - Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.io.IOException: org.apache.tomcat.util.http.fileupload.FileUploadException: the request was rejected because no multipart boundary was found</h1><div class="line"></div><p><b>type</b> Rapport d''exception</p><p><b>message</b> <u>Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.io.IOException: org.apache.tomcat.util.http.fileupload.FileUploadException: the request was rejected because no multipart boundary was found</u></p>

我试图在请求头和正文中设置一个边界,但我遇到了同样的错误。我有以下身体:正文

Azure API管理中的OpenAPI v3支持包括对预览功能的修复和改进。例如,它支持对多部分/表单数据内容类型的支持

在OpenAPI 3.0中,使用requestBody关键字而不是in: formData参数来定义请求主体(包括表单数据(。

"paths": {
"/api/rmt-create-request": {
"post": {
"tags": [
"RMT APIs"
],
"description": "Return newly created request data",
"operationId": "create-new-rmt-request",
"requestBody": {
"content": {
"multipart/form-data": {    // or  "application/x-www-form-urlencoded" - depending on what you need
"schema": {
"type": "object",
"properties": {
"rootNodeName": {
"type": "string",
"description": "Root node class name for item"
}
}
}
}
}
}
}
}
}

有关更多详细信息,您可以参考本文。

最新更新