如何修复okhttp不允许的405方法

时间:2017-11-16 13:59:49

标签: java http patch okhttp

我正在

  

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();

1 个答案:

答案 0 :(得分:0)

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