From 4cf445434104103c8e0d4e51f84391dc52317104 Mon Sep 17 00:00:00 2001 From: "miriam.baglioni" Date: Tue, 27 Oct 2020 17:46:19 +0100 Subject: [PATCH] changed from deprecated method to new one --- .../dnetlib/dhp/common/api/ZenodoAPIClient.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/dhp-common/src/main/java/eu/dnetlib/dhp/common/api/ZenodoAPIClient.java b/dhp-common/src/main/java/eu/dnetlib/dhp/common/api/ZenodoAPIClient.java index 8b66bd2da..5a24cfb44 100644 --- a/dhp-common/src/main/java/eu/dnetlib/dhp/common/api/ZenodoAPIClient.java +++ b/dhp-common/src/main/java/eu/dnetlib/dhp/common/api/ZenodoAPIClient.java @@ -60,7 +60,9 @@ public class ZenodoAPIClient implements Serializable { OkHttpClient httpClient = new OkHttpClient.Builder().connectTimeout(600, TimeUnit.SECONDS).build(); - RequestBody body = RequestBody.create(MEDIA_TYPE_JSON, json); + //RequestBody body = RequestBody.create(MEDIA_TYPE_JSON, json); + + RequestBody body = RequestBody.create(json, MEDIA_TYPE_JSON); Request request = new Request.Builder() .url(urlString) @@ -126,7 +128,8 @@ public class ZenodoAPIClient implements Serializable { OkHttpClient httpClient = new OkHttpClient.Builder().connectTimeout(600, TimeUnit.SECONDS).build(); - RequestBody body = RequestBody.create(MEDIA_TYPE_JSON, metadata); + //RequestBody body = RequestBody.create(MEDIA_TYPE_JSON, metadata); + RequestBody body = RequestBody.create(metadata, MEDIA_TYPE_JSON); Request request = new Request.Builder() .url(urlString + "/" + deposition_id) @@ -158,10 +161,13 @@ public class ZenodoAPIClient implements Serializable { OkHttpClient httpClient = new OkHttpClient.Builder().connectTimeout(600, TimeUnit.SECONDS).build(); + RequestBody body = RequestBody.create(json, MEDIA_TYPE_JSON); + Request request = new Request.Builder() .url(urlString + "/" + deposition_id + "/actions/publish") .addHeader("Authorization", "Bearer " + access_token) - .post(RequestBody.create(MEDIA_TYPE_JSON, json)) + //.post(RequestBody.create(MEDIA_TYPE_JSON, json)) + .post(body) .build(); try (Response response = httpClient.newCall(request).execute()) { @@ -191,10 +197,13 @@ public class ZenodoAPIClient implements Serializable { OkHttpClient httpClient = new OkHttpClient.Builder().connectTimeout(600, TimeUnit.SECONDS).build(); + RequestBody body = RequestBody.create(json, MEDIA_TYPE_JSON); + Request request = new Request.Builder() .url(urlString + "/" + deposition_id + "/actions/newversion") .addHeader("Authorization", "Bearer " + access_token) - .post(RequestBody.create(MEDIA_TYPE_JSON, json)) + //.post(RequestBody.create(MEDIA_TYPE_JSON, json)) + .post(body) .build(); try (Response response = httpClient.newCall(request).execute()) {