@SuppressWarnings("unchecked")
  public static BatchResponse batchRequest(
      TokenAuthData authData,
      List<Map<String, Object>> requests,
      String baseUrl,
      OkHttpClient client,
      ObjectMapper objectMapper) {
    try {
      Map<String, Object> batch = new LinkedHashMap<>();
      batch.put("requests", requests);

      Request.Builder requestBuilder = new Request.Builder().url(baseUrl + BATCH_URL);
      requestBuilder.header("Authorization", "Bearer " + authData.getToken());
      requestBuilder.post(
          RequestBody.create(
              MediaType.parse("application/json"), objectMapper.writeValueAsString(batch)));
      try (Response response = client.newCall(requestBuilder.build()).execute()) {
        int code = response.code();
        if (code >= 200 && code <= 299) {
          ResponseBody body = response.body();
          if (body == null) {
            // FIXME evaluate HTTP response and return whether to retry
            return new BatchResponse(new ImportResult(ImportResult.ResultType.ERROR));
          }
          Map<String, Object> responseData = objectMapper.readValue(body.bytes(), Map.class);
          return new BatchResponse(
              new ImportResult(ImportResult.ResultType.OK),
              (List<Map<String, Object>>) responseData.get("responses"));
        } else {
          // FIXME evaluate HTTP response and return whether to retry
          return new BatchResponse(new ImportResult(ImportResult.ResultType.ERROR));
        }
      }
    } catch (IOException e) {
      // TODO log
      e.printStackTrace();
      return new BatchResponse(new ImportResult(e));
    }
  }
Creates a Graph API batch request with required the authorization header.

@param authData the auth token
@param requests the batch request data
@param client the client to construct the request with
@param objectMapper the mapper to serialize data
extensions/data-transfer/portability-data-transfer-microsoft/src/main/java/org/datatransferproject/transfer/microsoft/common/RequestHelper.java