Okhttp를 사용하여 put 빈 RequestBody 실행
2842 단어 Android에 문제가 발생했습니다.
public Builder put(RequestBody body) {
return method("PUT", body);
}
...
public Builder method(String method, RequestBody body) {
if (method == null) throw new NullPointerException("method == null");
if (method.length() == 0) throw new IllegalArgumentException("method.length() == 0");
if (body != null && !HttpMethod.permitsRequestBody(method)) {
throw new IllegalArgumentException("method " + method + " must not have a request body.");
}
if (body == null && HttpMethod.requiresRequestBody(method)) {
throw new IllegalArgumentException("method " + method + " must have a request body.");
}
this.method = method;
this.body = body;
return this;
}
패스하지 않고 폴백 이상을 볼 수 있습니다. 이 경우 다음과 같이 처리할 수 있습니다.
RequestBody requestBody = RequestBody.create(null, new byte[]{});
Request request = new Request.Builder()
.url(url)
.header("Content-Type",contentType)
.put(requestBody)
.build();
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Okhttp를 사용하여 put 빈 RequestBody 실행특수한 원인으로 인해 클라이언트는put 요청을 해야 하지만 어떤 매개 변수도 필요하지 않습니다. 구체적인 매개 변수는 url에 있습니다. 그러나 Okhttp는 Put에서 RequestBody 매개 변수의 원본 코드를...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.