"Unacceptable content-type" 通过 sendinblue Java 客户端创建联系人时 API

"Unacceptable content-type" when creating contact via Java client of sendinblue API

真的很奇怪,因为我从 sendinblue API doc:

复制粘贴了代码示例
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/octet-stream");
RequestBody body = RequestBody.create(mediaType,"\"updateEnabled\":false,\"email\":\"example@email.com\"}");
Request request = new Request.Builder()
  .url("https://api.sendinblue.com/v3/contacts")
  .post(body)
  .addHeader("accept", "application/json")
  .addHeader("content-type", "application/json")
  .addHeader("api-key", "xxxxxxxxxxxxxxxxxx")
  .build();

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

响应是:

response code is: 406

response message is: Not Acceptable

response body is: {"code":"not_acceptable","message":"Unacceptable content-type"}

我用这个Java客户端:

<dependency>
    <groupId>com.sendinblue</groupId>
    <artifactId>sib-api-v3-sdk</artifactId>
    <version>3.0.1</version>
</dependency>

您需要将 content-type 设置为 JSON (application/json)。