code: @Override
    public Optional<HttpUriRequest> onNewRecord(RestEntry<JsonObject> record) {
      Preconditions.checkArgument(!StringUtils.isEmpty(accessToken), "Access token has not been acquired.");
      Preconditions.checkNotNull(record, "Record should not be null");
  
      RequestBuilder builder = null;
      JsonObject payload = null;
  
      if (batchSize > 1) {
        if (!batchRecords.isPresent()) {
          batchRecords = Optional.of(new JsonArray());
        }
        batchRecords.get().add(newSubrequest(record));
  
        if (batchRecords.get().size() < batchSize) { //No need to send. Return absent.
          return Optional.absent();
        }
  
        payload = newPayloadForBatch();
        builder = RequestBuilder.post().setUri(combineUrl(getCurServerHost(), batchResourcePath));
      } else {
        switch (operation) {
          case INSERT_ONLY_NOT_EXIST:
            builder = RequestBuilder.post();
            break;
          case UPSERT:
            builder = RequestBuilder.patch();
            break;
          default:
            throw new IllegalArgumentException(operation + " is not supported.");
        }
        builder.setUri(combineUrl(getCurServerHost(), record.getResourcePath()));
        payload = record.getRestEntryVal();
      }
      return Optional.of(newRequest(builder, payload));
    }
docs: For single request, creates HttpUriRequest and decides post/patch operation based on input parameter.
  
  For batch request, add the record into JsonArray as a subrequest and only creates HttpUriRequest with POST method if it filled the batch size.
  {@inheritDoc}
  @see org.apache.gobblin.writer.http.RestJsonWriter#onNewRecord(org.apache.gobblin.converter.rest.RestEntry)