【问题标题】:How to fix 405 Method not allowed with okhttp如何修复 405 方法不允许使用 okhttp
【发布时间】:2017-11-16 13:59:49
【问题描述】:

我明白了

405 方法不允许

当我尝试使用以下代码修补应用程序时。如何解决?

RequestBody body = new MultipartBuilder()
    .type(MultipartBuilder.FORM)
    .addFormDataPart("file", fileName, RequestBody.create(MediaType.parse("application/zip"), uploadZipFile))
    .addFormDataPart("artifactName", "gpswalker")
    .addFormDataPart("targetId", new Integer(SERV_ID).toString())
    .build();

Request request = new Request
    .Builder()
    .url(url)
    .patch(body)
    .addHeader("authorization", bearer_token)
    .addHeader("x-anypnt-org-id", ORG_ID)
    .addHeader("x-anypnt-env-id", ENV_ID)
    .addHeader("cache-control", "no-cache")
    .build();

Response response = client.newCall(request).execute();

【问题讨论】:

    标签: java http patch okhttp


    【解决方案1】:

    代码没有错,问题出在 URL 上。它是固定的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-01
      • 2012-06-29
      • 2013-03-13
      • 2016-03-08
      • 2014-09-19
      相关资源
      最近更新 更多