Example usage for org.apache.http.client.utils URLEncodedUtils format

List of usage examples for org.apache.http.client.utils URLEncodedUtils format

Introduction

In this page you can find the example usage for org.apache.http.client.utils URLEncodedUtils format.

Prototype

public static String format(final Iterable<? extends NameValuePair> parameters, final Charset charset) 

Source Link

Document

Returns a String that is suitable for use as an application/x-www-form-urlencoded list of parameters in an HTTP PUT or HTTP POST.

Usage

From source file:edu.scripps.fl.pubchem.web.session.PCWebSession.java

protected InputStream getBioActivityCompoundSummaryAsStream(List<Long> cids) throws Exception {
    List<NameValuePair> params = addParameters(new ArrayList<NameValuePair>(), "cid",
            StringUtils.join(cids, ","), "q", "cmp", "exptype", "csv");
    URI uri = URIUtils.createURI("http", SITE, 80, "/assay/assaytool.cgi",
            URLEncodedUtils.format(params, "UTF-8"), null);
    Document doc = new WaitOnRequestId(uri).asDocument();
    return getFtpLinkAsStream(doc);
}

From source file:com.gargoylesoftware.htmlunit.HttpWebConnection.java

/**
 * Creates an <tt>HttpMethod</tt> instance according to the specified parameters.
 * @param webRequest the request//from   w w w  .  j a  v  a2 s.  c o m
 * @param httpClientBuilder the httpClientBuilder that will be configured
 * @return the <tt>HttpMethod</tt> instance constructed according to the specified parameters
 * @throws IOException
 * @throws URISyntaxException
 */
@SuppressWarnings("deprecation")
private HttpUriRequest makeHttpMethod(final WebRequest webRequest, final HttpClientBuilder httpClientBuilder)
        throws IOException, URISyntaxException {

    final String charset = webRequest.getCharset();

    // Make sure that the URL is fully encoded. IE actually sends some Unicode chars in request
    // URLs; because of this we allow some Unicode chars in URLs. However, at this point we're
    // handing things over the HttpClient, and HttpClient will blow up if we leave these Unicode
    // chars in the URL.
    final URL url = UrlUtils.encodeUrl(webRequest.getUrl(), false, charset);

    // URIUtils.createURI is deprecated but as of httpclient-4.2.1, URIBuilder doesn't work here as it encodes path
    // what shouldn't happen here
    URI uri = URIUtils.createURI(url.getProtocol(), url.getHost(), url.getPort(), url.getPath(),
            escapeQuery(url.getQuery()), null);
    if (getVirtualHost() != null) {
        uri = URI.create(getVirtualHost());
    }
    final HttpRequestBase httpMethod = buildHttpMethod(webRequest.getHttpMethod(), uri);
    setProxy(httpMethod, webRequest);
    if (!(httpMethod instanceof HttpEntityEnclosingRequest)) {
        // this is the case for GET as well as TRACE, DELETE, OPTIONS and HEAD
        if (!webRequest.getRequestParameters().isEmpty()) {
            final List<NameValuePair> pairs = webRequest.getRequestParameters();
            final org.apache.http.NameValuePair[] httpClientPairs = NameValuePair.toHttpClient(pairs);
            final String query = URLEncodedUtils.format(Arrays.asList(httpClientPairs), charset);
            uri = URIUtils.createURI(url.getProtocol(), url.getHost(), url.getPort(), url.getPath(), query,
                    null);
            httpMethod.setURI(uri);
        }
    } else { // POST as well as PUT and PATCH
        final HttpEntityEnclosingRequest method = (HttpEntityEnclosingRequest) httpMethod;

        if (webRequest.getEncodingType() == FormEncodingType.URL_ENCODED && method instanceof HttpPost) {
            final HttpPost postMethod = (HttpPost) method;
            if (webRequest.getRequestBody() == null) {
                final List<NameValuePair> pairs = webRequest.getRequestParameters();
                final org.apache.http.NameValuePair[] httpClientPairs = NameValuePair.toHttpClient(pairs);
                final String query = URLEncodedUtils.format(Arrays.asList(httpClientPairs), charset);
                final StringEntity urlEncodedEntity = new StringEntity(query, charset);
                urlEncodedEntity.setContentType(URLEncodedUtils.CONTENT_TYPE);
                postMethod.setEntity(urlEncodedEntity);
            } else {
                final String body = StringUtils.defaultString(webRequest.getRequestBody());
                final StringEntity urlEncodedEntity = new StringEntity(body, charset);
                urlEncodedEntity.setContentType(URLEncodedUtils.CONTENT_TYPE);
                postMethod.setEntity(urlEncodedEntity);
            }
        } else if (FormEncodingType.MULTIPART == webRequest.getEncodingType()) {
            final Charset c = getCharset(charset, webRequest.getRequestParameters());
            final MultipartEntityBuilder builder = MultipartEntityBuilder.create().setLaxMode();
            builder.setCharset(c);

            for (final NameValuePair pair : webRequest.getRequestParameters()) {
                if (pair instanceof KeyDataPair) {
                    buildFilePart((KeyDataPair) pair, builder);
                } else {
                    builder.addTextBody(pair.getName(), pair.getValue(),
                            ContentType.create("text/plain", charset));
                }
            }
            method.setEntity(builder.build());
        } else { // for instance a PUT or PATCH request
            final String body = webRequest.getRequestBody();
            if (body != null) {
                method.setEntity(new StringEntity(body, charset));
            }
        }
    }

    configureHttpProcessorBuilder(httpClientBuilder, webRequest);

    // Tell the client where to get its credentials from
    // (it may have changed on the webClient since last call to getHttpClientFor(...))
    final CredentialsProvider credentialsProvider = webClient_.getCredentialsProvider();

    // if the used url contains credentials, we have to add this
    final Credentials requestUrlCredentials = webRequest.getUrlCredentials();
    if (null != requestUrlCredentials && webClient_.getBrowserVersion().hasFeature(URL_AUTH_CREDENTIALS)) {
        final URL requestUrl = webRequest.getUrl();
        final AuthScope authScope = new AuthScope(requestUrl.getHost(), requestUrl.getPort());
        // updating our client to keep the credentials for the next request
        credentialsProvider.setCredentials(authScope, requestUrlCredentials);
        httpContext_.removeAttribute(HttpClientContext.TARGET_AUTH_STATE);
    }

    // if someone has set credentials to this request, we have to add this
    final Credentials requestCredentials = webRequest.getCredentials();
    if (null != requestCredentials) {
        final URL requestUrl = webRequest.getUrl();
        final AuthScope authScope = new AuthScope(requestUrl.getHost(), requestUrl.getPort());
        // updating our client to keep the credentials for the next request
        credentialsProvider.setCredentials(authScope, requestCredentials);
        httpContext_.removeAttribute(HttpClientContext.TARGET_AUTH_STATE);
    }
    httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
    httpContext_.removeAttribute(HttpClientContext.CREDS_PROVIDER);

    return httpMethod;
}

From source file:org.mahasen.client.Search.java

/**
 * @param searchRequests/*from   www  . j  av  a2s . c  om*/
 * @param isAndSearch
 * @return
 * @throws IOException
 * @throws URISyntaxException
 * @throws AuthenticationExceptionException
 *
 * @throws MahasenClientException
 */
private HttpResponse sendRequest(Hashtable<String, Vector<String>> searchRequests, boolean isAndSearch)
        throws IOException, URISyntaxException, AuthenticationExceptionException, MahasenClientException {

    httpclient = new DefaultHttpClient();
    HttpResponse response = null;

    String userName = clientLoginData.getUserName();
    String passWord = clientLoginData.getPassWord();
    String hostAndPort = clientLoginData.getHostNameAndPort();
    String userId = clientLoginData.getUserId(userName, passWord);
    Boolean isLogged = clientLoginData.isLoggedIn();
    System.out.println(" Is Logged : " + isLogged);

    System.out.println(" Is Logged : " + isLogged);

    if (isLogged == true) {

        httpclient = WebClientSSLWrapper.wrapClient(httpclient);

        ArrayList<NameValuePair> qparams = new ArrayList<NameValuePair>();

        for (Map.Entry<String, Vector<String>> entry : searchRequests.entrySet()) {
            for (String value : entry.getValue()) {
                qparams.add(new BasicNameValuePair(entry.getKey(), value));
            }

        }

        /*qparams.add(new BasicNameValuePair("org.mahasen","value1"));
        qparams.add(new BasicNameValuePair("org.mahasen","value2"));
        qparams.add(new BasicNameValuePair("org.mahasen","value3"));*/
        URI uri;
        if (isAndSearch == true) {
            uri = URIUtils.createURI("https", hostAndPort, -1,
                    "/mahasen/multiple_and_search_request_ajaxprocessor.jsp",
                    URLEncodedUtils.format(qparams, "UTF-8"), null);
        } else {
            uri = URIUtils.createURI("https", hostAndPort, -1,
                    "/mahasen/multiple_or_search_request_ajaxprocessor.jsp",
                    URLEncodedUtils.format(qparams, "UTF-8"), null);
        }

        HttpPost httppost = new HttpPost(uri);
        System.out.println("executing request " + httppost.getRequestLine());
        response = httpclient.execute(httppost);

    } else {
        System.out.println("User has to be logged in to perform this function");
    }

    return response;
}

From source file:com.roadwarrior.vtiger.client.NetworkUtilities.java

/**
 * Fetches the list of friend data updates from the server
 * /*from  w w w .  j a v a2 s.com*/
 * @param account The account being synced.
 * @param authtoken The authtoken stored in AccountManager for this account
 * @param lastUpdated The last time that sync was performed
 * @return list The list of updates received from the server.
 */
public static List<User> fetchFriendUpdates(Account account, String auth_url, String authtoken,
        long serverSyncState/*Date lastUpdated*/, String type_contact)
        throws JSONException, ParseException, IOException, AuthenticationException {
    ArrayList<User> friendList = new ArrayList<User>();
    ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair(PARAM_OPERATION, "sync"));
    params.add(new BasicNameValuePair(PARAM_SESSIONNAME, sessionName));
    if (serverSyncState == 0)
        params.add(new BasicNameValuePair("modifiedTime", "878925701")); // il y a 14 ans.... 
    else
        params.add(new BasicNameValuePair("modifiedTime", String.valueOf(serverSyncState)));
    params.add(new BasicNameValuePair("elementType", type_contact)); // "Accounts,Leads , Contacts... 
    Log.d(TAG, "fetchFriendUpdates");
    //   params.add(new BasicNameValuePair(PARAM_QUERY, "select firstname,lastname,mobile,email,homephone,phone from Contacts;"));
    //        if (lastUpdated != null) {
    //            final SimpleDateFormat formatter =
    //                new SimpleDateFormat("yyyy/MM/dd HH:mm");
    //            formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
    //            params.add(new BasicNameValuePair(PARAM_UPDATED, formatter
    //                .format(lastUpdated)));
    //        }

    // HTTP GET REQUEST
    URL url = new URL(auth_url + "/webservice.php?" + URLEncodedUtils.format(params, "utf-8"));
    HttpURLConnection con;
    con = (HttpURLConnection) url.openConnection();
    con.setRequestMethod("GET");
    con.setRequestProperty("Content-length", "0");
    con.setRequestProperty("accept", "application/json");

    con.setUseCaches(false);
    con.setAllowUserInteraction(false);
    int timeout = 10000; // si tiemout pas assez important la connection echouait =>IOEXception
    con.setConnectTimeout(timeout);
    con.setReadTimeout(timeout);
    con.connect();
    int status = con.getResponseCode();

    LastFetchOperationStatus = true;
    if (status == HttpURLConnection.HTTP_OK) {
        // Succesfully connected to the samplesyncadapter server and
        // authenticated.
        // Extract friends data in json format.

        BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()));
        StringBuilder sb = new StringBuilder();
        String line;
        while ((line = br.readLine()) != null) {
            sb.append(line + "\n");
        }
        br.close();

        String response = sb.toString();
        Log.i(TAG, "--response--");
        // <Hack> to bypass vtiger 5.4 webservice bug:
        int idx = response.indexOf("{\"success");
        response = response.substring(idx);
        Log.i(TAG, response);
        // </Hack>
        Log.i(TAG, "--response end--");
        JSONObject result = new JSONObject(response);

        String success = result.getString("success");
        Log.i(TAG, "success is" + success);
        if (success == "true") {
            Log.i(TAG, result.getString("result"));
            final JSONObject data = new JSONObject(result.getString("result"));
            final JSONArray friends = new JSONArray(data.getString("updated"));
            // == VTiger updated contacts ==
            for (int i = 0; i < friends.length(); i++) {
                friendList.add(User.valueOf(friends.getJSONObject(i)));
            }
            // == Vtiger contacts deleted ===
            String deleted_contacts = data.getString("deleted");
            Log.d(TAG, deleted_contacts);
            Log.d(TAG, deleted_contacts.substring(deleted_contacts.indexOf("[")));
            List<String> items = Arrays.asList(
                    deleted_contacts.substring(deleted_contacts.indexOf("[") + 1, deleted_contacts.indexOf("]"))
                            .split("\\s*,\\s*"));
            for (int ii = 0; ii < items.size(); ii++) {
                Log.d(TAG, items.get(ii));
                if (items.get(ii).startsWith("\"4x")) // this is a contact
                {
                    //Log.d(TAG,"{\"id\":"+items.get(ii)+",\"d\":true,\"contact_no\":1}");
                    JSONObject item = new JSONObject(
                            "{\"id\":" + items.get(ii) + ",\"d\":true,\"contact_no\":\"CON1\"}");
                    friendList.add(User.valueOf(item));
                }
                if (items.get(ii).startsWith("\"3x")) // this is an account
                {
                    //Log.d(TAG,"{\"id\":"+items.get(ii)+",\"d\":true,\"contact_no\":1}");
                    JSONObject item = new JSONObject(
                            "{\"id\":" + items.get(ii) + ",\"d\":true,\"account_no\":\"ACC1\"}");
                    friendList.add(User.valueOf(item));
                }
                if (items.get(ii).startsWith("\"2x")) // this is a lead
                {
                    //Log.d(TAG,"{\"id\":"+items.get(ii)+",\"d\":true,\"contact_no\":1}");
                    JSONObject item = new JSONObject(
                            "{\"id\":" + items.get(ii) + ",\"d\":true,\"lead_no\":\"LEA1\"}");
                    friendList.add(User.valueOf(item));
                }
            }
        } else {
            LastFetchOperationStatus = false;
            // FIXME: else false...
            // possible error code :
            //{"success":false,"error":{"code":"AUTHENTICATION_REQUIRED","message":"Authencation required"}}
            //               throw new AuthenticationException();
        }
    } else {
        if (status == HttpURLConnection.HTTP_UNAUTHORIZED) {
            LastFetchOperationStatus = false;

            Log.e(TAG, "Authentication exception in fetching remote contacts");
            throw new AuthenticationException();
        } else {
            LastFetchOperationStatus = false;

            Log.e(TAG, "Server error in fetching remote contacts: ");
            throw new IOException();
        }
    }
    return friendList;
}

From source file:org.dvbviewer.controller.ui.fragments.StreamConfig.java

/**
 * Gets the video intent.//from  www  .ja  va 2 s  .c  om
 *
 * @return the video intent
 * @author RayBa
 * @date 07.04.2013
 */
private Intent getVideoIntent() {
    String videoUrl = null;
    String videoType = null;
    switch (mStreamType) {
    case STREAM_TYPE_DIRECT:
        switch (mFileType) {
        case FILE_TYPE_LIVE:
            videoUrl = liveUrl + mFileId + ".ts";
            break;
        case FILE_TYPE_RECORDING:
            videoUrl = mediaUrl + mFileId + ".ts";
            break;

        default:
            break;
        }
        videoType = "video/*";

        break;
    case STREAM_TYPE_TRANSCODE:
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("Preset", String.valueOf(qualitySpinner.getSelectedItemPosition())));
        params.add(new BasicNameValuePair("aspect", aspectSpinner.getSelectedItem().toString()));
        params.add(new BasicNameValuePair("ffPreset", ffmpegSpinner.getSelectedItem().toString()));

        /**
         * Check if height is set from user, otherwise the the default values are used
         */
        if (widthSpinner.getSelectedItemPosition() > 0) {
            params.add(new BasicNameValuePair("maxwidth", widthSpinner.getSelectedItem().toString()));
        }
        if (heightSpinner.getSelectedItemPosition() > 0) {
            params.add(new BasicNameValuePair("maxheight", heightSpinner.getSelectedItem().toString()));
        }

        /**
         * Calculate startposition in seconds
         */
        int hours = TextUtils.isEmpty(startHours.getText()) ? 0
                : Integer.valueOf(startHours.getText().toString());
        int minutes = TextUtils.isEmpty(startMinutes.getText()) ? 0
                : Integer.valueOf(startMinutes.getText().toString());
        int seconds = TextUtils.isEmpty(startSeconds.getText()) ? 0
                : Integer.valueOf(startSeconds.getText().toString());
        int start = 3600 * hours + 60 * minutes + seconds;
        params.add(new BasicNameValuePair("start", String.valueOf(start)));

        switch (mFileType) {
        case FILE_TYPE_LIVE:
            params.add(new BasicNameValuePair("chid", String.valueOf(mFileId)));
            break;
        case FILE_TYPE_RECORDING:
            params.add(new BasicNameValuePair("recid", String.valueOf(mFileId)));
            break;

        default:
            break;
        }
        String query = URLEncodedUtils.format(params, "utf-8");
        videoUrl = flashUrl + query;
        break;

    default:
        break;
    }
    Log.i(StreamConfig.class.getSimpleName(), "url: " + videoUrl);

    DVBViewerPreferences prefs = new DVBViewerPreferences(getActivity());
    boolean external = prefs.getPrefs().getBoolean(DVBViewerPreferences.KEY_STREAM_EXTERNAL_PLAYER, true);
    Intent videoIntent;
    if (external) {
        videoType = "video/mpeg";
        videoIntent = new Intent(Intent.ACTION_VIEW);
        videoIntent.setDataAndType(Uri.parse(videoUrl), videoType);
    } else {
        videoIntent = new Intent(getActivity(), VideoPlayerActivity.class);
        videoIntent.setData(Uri.parse(videoUrl));
    }
    return videoIntent;
}

From source file:de.geeksfactory.opacclient.apis.SISIS.java

@Override
public SearchRequestResult search(List<SearchQuery> query)
        throws IOException, OpacErrorException, JSONException {
    List<NameValuePair> params = new ArrayList<>();

    int index = 0;
    int restrictionIndex = 0;
    start();//from  w w w.j av a2 s . com

    params.add(new BasicNameValuePair("methodToCall", "submit"));
    params.add(new BasicNameValuePair("CSId", CSId));
    params.add(new BasicNameValuePair("methodToCallParameter", "submitSearch"));

    for (SearchQuery entry : query) {
        if (entry.getValue().equals("")) {
            continue;
        }
        if (entry.getSearchField() instanceof DropdownSearchField) {
            JSONObject data = entry.getSearchField().getData();
            if (data.getBoolean("restriction")) {
                params.add(new BasicNameValuePair("searchRestrictionID[" + restrictionIndex + "]",
                        entry.getSearchField().getId()));
                params.add(new BasicNameValuePair("searchRestrictionValue1[" + restrictionIndex + "]",
                        entry.getValue()));
                restrictionIndex++;
            } else {
                params.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
            }
        } else {
            if (index != 0) {
                params.add(new BasicNameValuePair("combinationOperator[" + index + "]", "AND"));
            }
            params.add(new BasicNameValuePair("searchCategories[" + index + "]", entry.getKey()));
            params.add(new BasicNameValuePair("searchString[" + index + "]", entry.getValue()));
            index++;
        }
    }

    if (index == 0) {
        throw new OpacErrorException(stringProvider.getString(StringProvider.NO_CRITERIA_INPUT));
    }
    if (index > 4) {
        throw new OpacErrorException(
                stringProvider.getQuantityString(StringProvider.LIMITED_NUM_OF_CRITERIA, 4, 4));
    }

    params.add(new BasicNameValuePair("submitSearch", "Suchen"));
    params.add(new BasicNameValuePair("callingPage", "searchParameters"));
    params.add(new BasicNameValuePair("numberOfHits", "10"));

    String html = httpGet(opac_url + "/search.do?" + URLEncodedUtils.format(params, "UTF-8"), ENCODING);
    return parse_search(html, 1);
}

From source file:tw.com.sti.store.api.android.AndroidApiService.java

/**
 * Login(01): /*from   ww  w  . j a  v a  2s . co  m*/
 */
public ApiInvoker<LoginRet> login(String userId, String password) {
    String[] paramNames = new String[] { "userId", "pwd" };
    String[] paramValues = new String[] { "" + userId, "" + password };
    String url = apiUrl.getLoginUrl();
    ApiDataParseHandler<LoginRet> handler = ApiDataParseHandler.LOGIN_RET_PARSE_HANDLER;
    List<NameValuePair> nvps = createRequestParams(paramNames, paramValues, false, null, userId, password);
    if (Logger.DEBUG) {
        L.d(url + "?" + URLEncodedUtils.format(nvps, "UTF-8"));
    }
    return new ApiInvoker<LoginRet>(this.config, handler, url, nvps);
}

From source file:com.ywh.train.logic.TrainClient.java

/**
 * ?/* w ww.j  ava 2s . c  om*/
 * @param from
 * @param to
 * @param startDate
 * @param rangDate
 * @return
 */
public List<TrainQueryInfo> queryTrain(String from, String to, String startDate, String rangDate) {
    log.debug("-------------------query train start-------------------");
    if (rangDate == null || rangDate.isEmpty()) {
        rangDate = "00:00--24:00";
    }
    List<NameValuePair> parameters = new ArrayList<NameValuePair>();
    parameters.add(new BasicNameValuePair("method", "queryLeftTicket"));
    parameters.add(new BasicNameValuePair("includeStudent", "00"));
    parameters.add(new BasicNameValuePair("orderRequest.from_station_telecode", Util.getCityCode(from)));
    parameters.add(new BasicNameValuePair("orderRequest.start_time_str", rangDate));
    parameters.add(new BasicNameValuePair("orderRequest.to_station_telecode", Util.getCityCode(to)));
    parameters.add(new BasicNameValuePair("orderRequest.train_date", startDate));
    parameters.add(new BasicNameValuePair("orderRequest.train_no", ""));
    parameters.add(new BasicNameValuePair("seatTypeAndNum", ""));
    parameters.add(new BasicNameValuePair("trainClass", "QB#D#Z#T#K#QT#"));
    parameters.add(new BasicNameValuePair("trainPassType", "QB"));
    HttpGet get = new HttpGet(Constants.QUERY_TRAIN_URL + URLEncodedUtils.format(parameters, HTTP.UTF_8));
    ResponseHandler<String> responseHandler = new BasicResponseHandler();
    String responseBody = null;
    List<TrainQueryInfo> all = new ArrayList<TrainQueryInfo>();
    try {
        responseBody = httpclient.execute(get, responseHandler);
        all = Util.parserQueryInfo(responseBody, startDate);
        //         for(TrainQueryInfo tInfo : all) {
        //            System.out.println(tInfo);
        //         }
    } catch (Exception e) {
        log.error(e);
    }
    log.debug("-------------------query train end-------------------");
    return all;

}

From source file:com.prey.net.PreyRestHttpClient.java

public PreyHttpResponse get(String url, Map<String, String> params, PreyConfig preyConfig) throws IOException {
    HttpGet method = new HttpGet(url + URLEncodedUtils.format(getHttpParamsFromMap(params), "UTF-8"));
    method.setHeader("Accept", "*/*");
    PreyLogger.d("Sending using 'GET' - URI: " + method.getURI());
    HttpResponse httpResponse = httpclient.execute(method);
    PreyHttpResponse response = new PreyHttpResponse(httpResponse);
    //PreyLogger.d("Response from server: " + response.toString());
    return response;
}

From source file:io.gs2.inbox.Gs2InboxClient.java

/**
 * ??????<br>//from   ww  w.ja  v  a 2 s .co  m
 * <br>
 * - : 50??5<br>
 * <br>
 *
 * @param request 
        
 * @return ?
        
 */

public DescribeMessageResult describeMessage(DescribeMessageRequest request) {

    String url = Gs2Constant.ENDPOINT_HOST + "/inbox/"
            + (request.getInboxName() == null || request.getInboxName().equals("") ? "null"
                    : request.getInboxName())
            + "/message";

    List<NameValuePair> queryString = new ArrayList<>();
    if (request.getPageToken() != null)
        queryString.add(new BasicNameValuePair("pageToken", String.valueOf(request.getPageToken())));
    if (request.getLimit() != null)
        queryString.add(new BasicNameValuePair("limit", String.valueOf(request.getLimit())));

    if (queryString.size() > 0) {
        url += "?" + URLEncodedUtils.format(queryString, "UTF-8");
    }
    HttpGet get = createHttpGet(url, credential, ENDPOINT, DescribeMessageRequest.Constant.MODULE,
            DescribeMessageRequest.Constant.FUNCTION);
    if (request.getRequestId() != null) {
        get.setHeader("X-GS2-REQUEST-ID", request.getRequestId());
    }

    get.setHeader("X-GS2-ACCESS-TOKEN", request.getAccessToken());

    return doRequest(get, DescribeMessageResult.class);

}