protected <R> HttpRequestBase createHttpRequest(ServiceRequest<R> request) throws IOException, WssServiceException {
        HttpPost httpRequest = new HttpPost(serviceUrl);
        httpRequest.setHeader("Accept", ClientConstants.APPLICATION_JSON);

        RequestType requestType = request.type();
        List<NameValuePair> nvps = new ArrayList<>();
        nvps.add(new BasicNameValuePair(APIConstants.PARAM_REQUEST_TYPE, requestType.toString()));
        nvps.add(new BasicNameValuePair(APIConstants.PARAM_AGENT, request.agent()));
        nvps.add(new BasicNameValuePair(APIConstants.PARAM_AGENT_VERSION, request.agentVersion()));
        nvps.add(new BasicNameValuePair(APIConstants.PARAM_TOKEN, request.orgToken()));
        nvps.add(new BasicNameValuePair(APIConstants.USER_KEY, request.userKey()));
        nvps.add(new BasicNameValuePair(APIConstants.PARAM_REQUESTER_EMAIL, request.requesterEmail()));
        nvps.add(new BasicNameValuePair(APIConstants.PARAM_PRODUCT, request.product()));
        nvps.add(new BasicNameValuePair(APIConstants.PARAM_PRODUCT_VERSION, request.productVersion()));
        nvps.add(new BasicNameValuePair(APIConstants.PARAM_TIME_STAMP, String.valueOf(request.timeStamp())));
        nvps.add(new BasicNameValuePair(APIConstants.PARAM_PLUGIN_VERSION, String.valueOf(request.pluginVersion())));
        nvps.add(new BasicNameValuePair(APIConstants.AGGREGATE_MODULES, String.valueOf(request.aggregateModules())));
        nvps.add(new BasicNameValuePair(APIConstants.PRESERVE_MODULE_STRUCTURE, String.valueOf(request.preserveModuleStructure())));
        nvps.add(new BasicNameValuePair(APIConstants.AGGREGATE_PROJECT_NAME, request.aggregateProjectName()));
        nvps.add(new BasicNameValuePair(APIConstants.AGGREGATE_PROJECT_TOKEN, request.aggregateProjectToken()));
        nvps.add(new BasicNameValuePair(APIConstants.LOG_DATA, request.logData()));
        nvps.add(new BasicNameValuePair(APIConstants.SCAN_COMMENT, request.scanComment()));
        nvps.add(new BasicNameValuePair(APIConstants.PRODUCT_TOKEN, request.productToken()));

        if (request.extraProperties() != null) {
            String strExtraProperties = gson.toJson(request.extraProperties());
            nvps.add(new BasicNameValuePair(APIConstants.EXTRA_PROPERTIES, strExtraProperties));
        } else {
            nvps.add(new BasicNameValuePair(APIConstants.EXTRA_PROPERTIES, "{}"));
        }

        String jsonDiff = null;
        switch (requestType) {
            case UPDATE:
                UpdateInventoryRequest updateInventoryRequest = (UpdateInventoryRequest) request;
                nvps.add(new BasicNameValuePair(APIConstants.SCAN_SUMMARY_INFO, gson.toJson(updateInventoryRequest.getScanSummaryInfo())));
                nvps.add(new BasicNameValuePair(APIConstants.PARAM_UPDATE_TYPE, updateInventoryRequest.getUpdateType().toString()));
                jsonDiff = gson.toJson(updateInventoryRequest.getProjects());
                break;
            case CHECK_POLICIES:
                jsonDiff = gson.toJson(((CheckPoliciesRequest) request).getProjects());
                break;
            case CHECK_POLICY_COMPLIANCE:
                CheckPolicyComplianceRequest checkPolicyComplianceRequest = (CheckPolicyComplianceRequest) request;
                nvps.add(new BasicNameValuePair(APIConstants.SCAN_SUMMARY_INFO, this.gson.toJson(checkPolicyComplianceRequest.getScanSummaryInfo())));
                nvps.add(new BasicNameValuePair(APIConstants.PARAM_FORCE_CHECK_ALL_DEPENDENCIES,
                        String.valueOf(checkPolicyComplianceRequest.isForceCheckAllDependencies())));
                jsonDiff = gson.toJson(checkPolicyComplianceRequest.getProjects());
                break;
            case CHECK_VULNERABILITIES:
                jsonDiff = gson.toJson(((CheckVulnerabilitiesRequest) request).getProjects());
                break;
            case GET_DEPENDENCY_DATA:
                jsonDiff = gson.toJson(((GetDependencyDataRequest) request).getProjects());
                break;
            case SUMMARY_SCAN:
                SummaryScanRequest summaryScanRequest = (SummaryScanRequest) request;
                jsonDiff = gson.toJson(summaryScanRequest.getProjects());
                break;
            case GET_CONFIGURATION:
                jsonDiff = gson.toJson(((ConfigurationRequest) request).getProjects());
                break;
            default:
                break;
        }

        // compress json before sending
        String compressedString = ZipUtils.compressString(jsonDiff);
        nvps.add(new BasicNameValuePair(APIConstants.PARAM_DIFF, compressedString));

        httpRequest.setEntity(new UrlEncodedFormEntity(nvps, UTF_8));

        // whitesource service http request size should be below 200 MB
        String httpRequestJson = gson.toJson(httpRequest);
        //        if(httpRequestJson.getBytes().length > APIConstants.MAX_POST_SIZE) {
        //            logger.error("WhiteSource service http request size have exceeded max limit " + APIConstants.MAX_POST_SIZE + " bytes");
        //            throw new WssServiceException("WhiteSource service http request size have exceeded max limit " + APIConstants.MAX_POST_SIZE + " bytes");
        //        }

        return httpRequest;
    }
protected < R > HttpRequestBase createHttpRequest ( ServiceRequest < R > request ) throws IOException , WssServiceException { HttpPost httpRequest = new HttpPost ( serviceUrl ) ; httpRequest . setHeader ( "Accept" , ClientConstants . APPLICATION_JSON ) ; RequestType requestType = request . type ( ) ; List < NameValuePair > nvps = new ArrayList < > ( ) ; nvps . add ( new BasicNameValuePair ( APIConstants . PARAM_REQUEST_TYPE , requestType . toString ( ) ) ) ; nvps . add ( new BasicNameValuePair ( APIConstants . PARAM_AGENT , request . agent ( ) ) ) ; nvps . add ( new BasicNameValuePair ( APIConstants . PARAM_AGENT_VERSION , request . agentVersion ( ) ) ) ; nvps . add ( new BasicNameValuePair ( APIConstants . PARAM_TOKEN , request . orgToken ( ) ) ) ; nvps . add ( new BasicNameValuePair ( APIConstants . USER_KEY , request . userKey ( ) ) ) ; nvps . add ( new BasicNameValuePair ( APIConstants . PARAM_REQUESTER_EMAIL , request . requesterEmail ( ) ) ) ; nvps . add ( new BasicNameValuePair ( APIConstants . PARAM_PRODUCT , request . product ( ) ) ) ; nvps . add ( new BasicNameValuePair ( APIConstants . PARAM_PRODUCT_VERSION , request . productVersion ( ) ) ) ; nvps . add ( new BasicNameValuePair ( APIConstants . PARAM_TIME_STAMP , String . valueOf ( request . timeStamp ( ) ) ) ) ; nvps . add ( new BasicNameValuePair ( APIConstants . PARAM_PLUGIN_VERSION , String . valueOf ( request . pluginVersion ( ) ) ) ) ; nvps . add ( new BasicNameValuePair ( APIConstants . AGGREGATE_MODULES , String . valueOf ( request . aggregateModules ( ) ) ) ) ; nvps . add ( new BasicNameValuePair ( APIConstants . PRESERVE_MODULE_STRUCTURE , String . valueOf ( request . preserveModuleStructure ( ) ) ) ) ; nvps . add ( new BasicNameValuePair ( APIConstants . AGGREGATE_PROJECT_NAME , request . aggregateProjectName ( ) ) ) ; nvps . add ( new BasicNameValuePair ( APIConstants . AGGREGATE_PROJECT_TOKEN , request . aggregateProjectToken ( ) ) ) ; nvps . add ( new BasicNameValuePair ( APIConstants . LOG_DATA , request . logData ( ) ) ) ; nvps . add ( new BasicNameValuePair ( APIConstants . SCAN_COMMENT , request . scanComment ( ) ) ) ; nvps . add ( new BasicNameValuePair ( APIConstants . PRODUCT_TOKEN , request . productToken ( ) ) ) ; if ( request . extraProperties ( ) != null ) { String strExtraProperties = gson . toJson ( request . extraProperties ( ) ) ; nvps . add ( new BasicNameValuePair ( APIConstants . EXTRA_PROPERTIES , strExtraProperties ) ) ; } else { nvps . add ( new BasicNameValuePair ( APIConstants . EXTRA_PROPERTIES , "{}" ) ) ; } String jsonDiff = null ; switch ( requestType ) { case UPDATE : UpdateInventoryRequest updateInventoryRequest = ( UpdateInventoryRequest ) request ; nvps . add ( new BasicNameValuePair ( APIConstants . SCAN_SUMMARY_INFO , gson . toJson ( updateInventoryRequest . getScanSummaryInfo ( ) ) ) ) ; nvps . add ( new BasicNameValuePair ( APIConstants . PARAM_UPDATE_TYPE , updateInventoryRequest . getUpdateType ( ) . toString ( ) ) ) ; jsonDiff = gson . toJson ( updateInventoryRequest . getProjects ( ) ) ; break ; case CHECK_POLICIES : jsonDiff = gson . toJson ( ( ( CheckPoliciesRequest ) request ) . getProjects ( ) ) ; break ; case CHECK_POLICY_COMPLIANCE : CheckPolicyComplianceRequest checkPolicyComplianceRequest = ( CheckPolicyComplianceRequest ) request ; nvps . add ( new BasicNameValuePair ( APIConstants . SCAN_SUMMARY_INFO , this . gson . toJson ( checkPolicyComplianceRequest . getScanSummaryInfo ( ) ) ) ) ; nvps . add ( new BasicNameValuePair ( APIConstants . PARAM_FORCE_CHECK_ALL_DEPENDENCIES , String . valueOf ( checkPolicyComplianceRequest . isForceCheckAllDependencies ( ) ) ) ) ; jsonDiff = gson . toJson ( checkPolicyComplianceRequest . getProjects ( ) ) ; break ; case CHECK_VULNERABILITIES : jsonDiff = gson . toJson ( ( ( CheckVulnerabilitiesRequest ) request ) . getProjects ( ) ) ; break ; case GET_DEPENDENCY_DATA : jsonDiff = gson . toJson ( ( ( GetDependencyDataRequest ) request ) . getProjects ( ) ) ; break ; case SUMMARY_SCAN : SummaryScanRequest summaryScanRequest = ( SummaryScanRequest ) request ; jsonDiff = gson . toJson ( summaryScanRequest . getProjects ( ) ) ; break ; case GET_CONFIGURATION : jsonDiff = gson . toJson ( ( ( ConfigurationRequest ) request ) . getProjects ( ) ) ; break ; default : break ; } String compressedString = ZipUtils . compressString ( jsonDiff ) ; nvps . add ( new BasicNameValuePair ( APIConstants . PARAM_DIFF , compressedString ) ) ; httpRequest . setEntity ( new UrlEncodedFormEntity ( nvps , UTF_8 ) ) ; String httpRequestJson = gson . toJson ( httpRequest ) ; return httpRequest ; }
The method create the HTTP post request to be sent to the remote service.

@param request Request to service.
@return Newly created HTTP post request.
@throws IOException In case of error creating the request.