code: private Integer getNextOrdinalForMethodId(int methodId, String pathName) throws Exception {
          String pathInfo = doGet(BASE_PATH + uriEncode(pathName), new BasicNameValuePair[0]);
          JSONObject pathResponse = new JSONObject(pathInfo);
  
          JSONArray enabledEndpoints = pathResponse.getJSONArray("enabledEndpoints");
          int lastOrdinal = 0;
          for (int x = 0; x < enabledEndpoints.length(); x++) {
              if (enabledEndpoints.getJSONObject(x).getInt("overrideId") == methodId) {
                  lastOrdinal++;
              }
          }
          return lastOrdinal + 1;
      }
docs: Get the next available ordinal for a method ID
  
  @param methodId ID of method
  @return value of next ordinal
  @throws Exception exception