Source:
<code>public HttpRequestBase formatRequest() { URIBuilder uriBuilder = getRepository().getURIBuilder(fAuthIsRequired); Gson gson = new Gson(); String json = null; URI uri = null; try { String path = new StringBuilder(uriBuilder.getPath()).append("/changes/") .append(getId()) .append("/revisions/").append(getRevision()) .append("/drafts") .toString(); uriBuilder.setPath(path); uri = new URI(URIUtil.toUnencodedString(uriBuilder.build())); } catch (URISyntaxException e) { EGerritCorePlugin.logError("URI syntax exception", e); } HttpPut httpPut = new HttpPut(uri); JsonObject jsonCommentInput = new JsonObject(); <START> jsonCommentInput.addProperty("id", fCommentInfo.getId()); jsonCommentInput.addProperty("inReplyTo", fCommentInfo.getInReplyTo()); jsonCommentInput.addProperty("kind", fCommentInfo.getKind()); jsonCommentInput.addProperty("line", fCommentInfo.getLine()); jsonCommentInput.addProperty("message", fCommentInfo.getMessage()); jsonCommentInput.addProperty("patch_set", fCommentInfo.getPatch_set()); jsonCommentInput.addProperty("path", fCommentInfo.getPath()); json = gson.toJson(fCommentInfo.getRange()); if (json != null && json.compareTo("null") != 0) { jsonCommentInput.addProperty("range", json); } jsonCommentInput.addProperty("side", fCommentInfo.getSide()); jsonCommentInput.addProperty("updated", fCommentInfo.getUpdated()); if (json != null && json.compareTo("null") != 0) { json = gson.toJson(fCommentInfo.getAuthor()); jsonCommentInput.addProperty("author", json); } StringEntity input = null; try { input = new StringEntity(jsonCommentInput.toString()); } catch (UnsupportedEncodingException e) { EGerritCorePlugin.logError("URI error encoding CommentInfo", e); } <END> input.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); httpPut.setEntity(input); return httpPut; }</code><technical_language>Instead of setting field, is a method json.getAsJsonObject ? andf class argument I setting field field is good, able structure defined in REST API fill data after, defining field field</technical_language>

Target:
public HttpRequestBase formatRequest() { URIBuilder uriBuilder = getRepository().getURIBuilder(fAuthIsRequired); Gson gson = new Gson(); String json = null; URI uri = null; try { String path = new StringBuilder(uriBuilder.getPath()).append("/changes/") .append(getId()) .append("/revisions/").append(getRevision()) .append("/drafts") .toString(); uriBuilder.setPath(path); uri = new URI(URIUtil.toUnencodedString(uriBuilder.build())); } catch (URISyntaxException e) { EGerritCorePlugin.logError("URI syntax exception", e); } HttpPut httpPut = new HttpPut(uri); JsonObject jsonCommentInput = new JsonObject(); jsonCommentInput.addProperty("id", fCommentInfo.getId()); jsonCommentInput.addProperty("inReplyTo", fCommentInfo.getInReplyTo()); jsonCommentInput.addProperty("line", fCommentInfo.getLine()); jsonCommentInput.addProperty("message", fCommentInfo.getMessage()); jsonCommentInput.addProperty("path", fCommentInfo.getPath()); json = gson.toJson(fCommentInfo.getRange()); if (json != null && json.compareTo("null") != 0) { jsonCommentInput.addProperty("range", json); } jsonCommentInput.addProperty("side", fCommentInfo.getSide()); if (json != null && json.compareTo("null") != 0) { json = gson.toJson(fCommentInfo.getAuthor()); jsonCommentInput.addProperty("author", json); } StringEntity input = null; try { input = new StringEntity(jsonCommentInput.toString()); } catch (UnsupportedEncodingException e) { EGerritCorePlugin.logError("URI error encoding CommentInfo", e); } input.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); httpPut.setEntity(input); return httpPut; }