Postman 空手道API:获取;405“不允许使用方法”;使用PUT方法发送请求时出错

Postman 空手道API:获取;405“不允许使用方法”;使用PUT方法发送请求时出错,postman,karate,Postman,Karate,当使用PUT方法发送请求时,我遇到以下错误 1 < 405 1 < Allow: GET,HEAD,POST,OPTIONS 1 < Content-Type: text/html; charset=iso-8859-1 1 < Date: Mon, 17 Aug 2020 04:01:07 GMT 1 < Server: Apache 1 < Vary: Accept-Encoding 1 < Via: 1.1 <!DOCTYPE HTML P

当使用PUT方法发送请求时,我遇到以下错误

1 < 405
1 < Allow: GET,HEAD,POST,OPTIONS
1 < Content-Type: text/html; charset=iso-8859-1
1 < Date: Mon, 17 Aug 2020 04:01:07 GMT
1 < Server: Apache
1 < Vary: Accept-Encoding
1 < Via: 1.1 
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>405 Method Not Allowed</title>
</head><body>
<h1>Method Not Allowed</h1>
<p>The requested method PUT is not allowed for the URL /xyz/abc/def/-1.</p>
</body></html>

[Fatal Error] :1:50: White spaces are required between publicId and systemId.
13:01:07.437 [main] WARN  com.intuit.karate - xml parsing failed, response data type set to string: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 50; White spaces are required between publicId and systemId.
有人能指导我解决这个问题吗

注:

  • API支持PUT方法,我们尝试处理的请求是PUT方法
  • 同样的请求也适用于邮递员
  • 我发出请求的代码

    场景:常见操作
    *string testdata=read(sourceFilename)
    *def arr=LIB.getJsonArrayForElement(testdata,“testCases”)
    *评估日志(arr[cnt].caseId)
    #设置c
    *def c=arr[cnt]。请求。c==null?“Y':arr[cnt].request.c
    #设置b
    *def b=arr[cnt]。请求。b==null?“Z':arr[cnt].请求.b
    #设置s
    *def s=arr[cnt]。请求。s==null?“”:arr[cnt].request.s
    #设置一
    *def i=arr[cnt]。请求。i==null?“”:arr[cnt].request.i
    #设置d
    *def d=arr[cnt]。请求。d==null?false:arr[cnt].request.d
    #设置v
    *def v=arr[cnt]。请求。v==null?“”:arr[cnt].request.v
    #设置f
    *def f=arr[cnt]。请求。f==null?false:arr[cnt].request.f
    #布景
    *def es=arr[cnt]。应为。s==null?999999:arr[cnt]。应为.s
    *如果(es==999999&&typeof ess!='undefined')空手道.set('es',ess)的值
    *如果(es==9999999)空手道组('es',200)进行评估
    #准备端点
    *def endpoint=utils.getUrl(c、b、s、i、v、d)
    给定url端点
    和请求arr[cnt].request.body
    当方法
    然后断言响应==es
    #对于我们预期为404的情况
    *如果(es==404)空手道中止()
    #案件!=404
    *def expRes=“”
    *如果(es!=204)空手道.set('expRes',arr[cnt].expired.body),则求值
    *def actRes=''
    *如果(es!=204)空手道,则评估。设置('actRes',响应)
    
    match actRes==expRes
    这个请求对我来说绝对有效,所以很可能您的服务器期望其他东西,或者可能是您的服务器中的一个实际错误。请与拥有服务器的团队合作,您应该能够立即发现问题

    * url 'http://httpbin.org'
    * header X-Client-Id = 'test'
    * path 'put'
    * request
    """
    {
      "i": {
        "x1": {
          "q": 10
        },
        "x2": {
          "q": 50
        }
      }
    }
    """
    * method put
    
    其他故障排除提示:

    • 邮递员会自动添加一些邮件头,如
      Accept
      注意这一点,并在需要时添加
    • 空手道附加
      ;默认情况下,将charset=UTF-8
      添加到
      内容类型
      标题,在极少数情况下,服务器不喜欢该标题(很可能是服务器端的错误)-您可以通过
      *配置charset=null
      禁用此功能-请参阅

    答案很清楚,PUT是不允许的。你不想发帖吗?并非所有的API都支持每个HTTP谓词。API支持PUT,我们需要使用PUT方法发出请求。它不支持您正在使用的URL。请参见以
    Allow
    开头的行,它不包含
    PUT
    ,这意味着该特定URL不支持
    PUT
    。也许URL缺少一个片段?@ranisalt我已经添加了一个注释。Postman可以处理相同的请求。@Shafiqlkabir然后使用Postman:)好的,但认真地说,提供一个cURL命令作为问题的一部分。否则,请假设空手道不支持你想要的。感谢你的迅速反应并帮助彼得。我们已经发现我们的代理服务器存在问题。
    * url 'http://httpbin.org'
    * header X-Client-Id = 'test'
    * path 'put'
    * request
    """
    {
      "i": {
        "x1": {
          "q": 10
        },
        "x2": {
          "q": 50
        }
      }
    }
    """
    * method put