code: public <T> T to(String tailAPIUrl, Class<T> type, T instance) throws IOException {
          HttpURLConnection connection = null;
          try {
              connection = setupConnection(root.getAPIUrl(tailAPIUrl));
              if (hasAttachments()) {
                  submitAttachments(connection);
              } else if (hasOutput()) {
                   submitData(connection);
              } else if (PUT.equals(method)) {
                  // PUT requires Content-Length: 0 even when there is no body (eg: API for protecting a branch)
                  connection.setDoOutput(true);
                  connection.setFixedLengthStreamingMode(0);
              }
  
              try {
                  return parse(connection, type, instance);
              } catch (IOException e) {
                  handleAPIError(e, connection);
              }
  
              return null;
          } finally {
              if (connection != null) {
                  connection.disconnect();
              }
          }
      }
docs: Opens the HTTP(S) connection, submits any data and parses the response.
  Will throw an error
  
  @param <T>        The return type of the method
  @param tailAPIUrl The url to open a connection to (after the host and namespace)
  @param type       The type of the response to be deserialized from
  @param instance   The instance to update from the response
  @return An object of type T
  @throws java.io.IOException on gitlab api error