79822909

Date: 2025-11-18 00:47:38
Score: 0.5
Natty:
Report link

@VGR 's comment to not use URLEncoder was completely wrong.

It turns out that the solution is:

String q = URLEncoder.encode("mimeType=\"application/vnd.google-apps.presentation\"", StandardCharsets.UTF_8);                      String f = URLEncoder.encode("files(id,name,webViewLink)", StandardCharsets.UTF_8);             

Then to pass
String uri = "https://www.googleapis.com/drive/v3/files?q=" + q + "&fields=" + f + "&key=mykey"
to

HttpRequest httpreq = HttpRequest.newBuilder().uri(URI.create(uri)).header("Authorization", "Bearer " + result.getString("access_token")).build();

The key is the escaped " (double quotes) around the mimeType:

\"application/vnd.google-apps.presentation\"
and to URL encode all of it as well as the fields value.
Reasons:
  • Whitelisted phrase (-1): solution is
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @VGR
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Alan