I enabled wire and header logging and put into a Pastie [1]. But all looks
fine ... i think so. But at the moment it didn't work. You can see the
response from Google is "title":"Untitled". I hope u can help me :-) My
assumption is the json content are not correctly or the parts of the
content. In the second Pastie [2], i want to POST a new Folder and same
thing, it looks fine... but didn't really work.
Second Example:
@Named("Files:folder")
@POST
@OAuthScopes(DriveConstants.DRIVE_SCOPE)
@Path("upload/drive/v2/files")
@Consumes
@Produces(MediaType.APPLICATION_JSON)
@ResponseParser(ParseObjectFrom.class)
ListenableFuture<DriveResponseUpload> putContainer
(@BinderParam(BindUploadMetadataToContainer.class) DriveRequest
driveRequest,
@QueryParam(value = "uploadType") String uploadType);
BindUploadMetadataToContainer.java
@Override
public <R extends HttpRequest> R bindToRequest(R request, Object input)
{
checkArgument(checkNotNull(input, "input") instanceof DriveRequest,
"this binder is only valid for DriveObject");
DriveRequest driveRequest = DriveRequest.class.cast(input);
Gson gson = new Gson();
String payLoad = gson.toJson(driveRequest);
try {
request.setPayload(payLoad.getBytes("UTF8"));
request.getPayload().getContentMetadata().setContentType(driveRequest.getMimeType());
} catch (UnsupportedEncodingException ueEx) {
System.err.println(ueEx.toString());
}
return request;
}
If i change to @Produces("application/vnd.google-apps.folder"), it works
but without the correct title ("Untitled"). It looks sometimes like a
problem from Google but i want to know what you are thinking about :-)
Cheers,
Josh
[1] http://pastie.org/9250551
[2] http://pastie.org/9250579