首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >IIB 10.19其余的GET操作不被邮递员调用

问IIB 10.19其余的GET操作不被邮递员调用
EN

Stack Overflow用户
提问于 2020-04-04 18:12:14
回答 1查看 743关注 0票数 0

尝试从浏览器和邮递员调用基本REST GET操作。

在浏览器中,URL为http://localhost:7800/restrequest_api/v1/4

其中4是我要传递的UserNumber。

它正在被成功地调用。

但是从PostMan我无法调用它。

尝试了http://localhost:7800/restrequest_api/v1,Content-Type头作为application/x-www-form-urlencoded,选择的主体为x-www-form-urlencoded,键为UserNumber,值为4

这是错误的

代码语言:javascript
复制
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>404 Not Found</title>
</head>

<body>
    <h1>404 Not Found</h1>
    <p>
        BIP6311E: REST API '&apos;RESTRequest_API&apos;' does not support method '&apos;GET&apos;' for URL
        '&apos;http://localhost:7800/restrequest_api/v1&apos;'.
    </p>
    <hr>
</body>

</html>

请注意: CORS已启用:

代码语言:javascript
复制
mqsichangeproperties TESTNODE_hghatak -e default -o HTTPConnector -n corsEnabled -v true

mqsichangeproperties TESTNODE_hghatak -b httplistener -o HTTPConnector -n corsEnabled -v true

mqsistop TESTNODE_hghatak

mqsistart TESTNODE_hghatak

下面是用于开发的Swagger文件:

代码语言:javascript
复制
{
  "swagger" : "2.0",
  "info" : {
    "title" : "RESTRequest_API",
    "version" : "1.0.0",
    "description" : "RESTRequest_API"
  },
  "paths" : {
    "/{UserNumber}" : {
      "get" : {
        "operationId" : "getUser",
        "responses" : {
          "200" : {
            "description" : "The operation was successful.",
            "schema" : {
              "$ref" : "#/definitions/Output"
            }
          }
        },
        "produces" : [ "application/json" ],
        "description" : "Retrieve User",
        "parameters" : [ {
          "required" : true,
          "name" : "UserNumber",
          "in" : "path",
          "type" : "string"
        } ]
      }
    }
  },
  "basePath" : "/restrequest_api/v1",
  "definitions" : {
    "Output" : {
      "type" : "object",
      "properties" : {
        "firstName" : {
          "type" : "string"
        },
        "lastName" : {
          "type" : "string"
        },
        "userDetails" : {
          "type" : "string"
        },
        "userNumber" : {
          "type" : "string"
        }
      }
    }
  },
  "host" : "localhost:7800"
}

有什么问题吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-04-06 15:46:33

只需在POSTMAN中选择GET作为您的操作,在postman中的BODY选项卡中选择"none“选项。确保您在postman中使用的URL与在浏览器中使用的相同,即

解释:

您的swagger文件指示正在执行GET操作,因此不需要发送有效负载。因此,选择内容类型是不适用的。在swagger文件的parameters部分中,提到了" In“:path”,这意味着您必须在url中传递一个路径参数,即 ,其中4是示例中的路径参数。您可以查看下面的postman链接,该链接提供了有关发送参数=> https://learning.postman.com/docs/postman/sending-api-requests/requests/#sending-parameters的更多详细信息

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61032619

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档