function to perform a Post http request.

@param uri the URI of the request.
@param params the form params to be posted, optional.
@return the response object type of which is specified by user.
@throws UnsupportedEncodingException, IOException
323111
public T httpPost(final URI uri, final List<Pair<String, String>> params) throws IOException {
    // shortcut if the passed url is invalid.
    if (null == uri) {
      logger.error(" unable to perform httpPost as the passed uri is null.");
      return null;
    }

    final HttpPost post = new HttpPost(uri);
    return this.sendAndReturn(completeRequest(post, params));
  }
119527
public JSONObject requestApproval(HashMap<String, String> params) throws JSONException {
        return oClient.post("/hr/v3/fp/submissions", params);
    }
896508
function POST(uri, params) {
	var form = new FormData();

	for (var i in params) {
		form.append(i, params[i]);
	}

	const requestURL = `${uri}`;
	log(`request URL: ${requestURL}`);

	return fetch(requestURL, { method: 'POST', compress: compress, body: form, headers: { 'Content-Type': 'multipart/form-data; boundary='+form.getBoundary() } })
    .then(function handleRequest(res) {
			const status = res.status;
			if (status != 200) {
				const error = new Error(`Request failed: ${status}`);
				error.status = status;
				throw error;
			}
			return res.json();
		})
		.catch(error => {
			log(`error: ${error}`);
			throw error;
		});
}
605982
def request(uri:, request_options: {}, parameters: {})
      opts = {
        uri: uri,
        request_options: request_options,
        parameters: @default_parameters.merge(parameters)
      }
      parse_response(http_service.perform_request(opts))
    end
41245
private byte[] encodeParameters(Map<String, String> params, String paramsEncoding) {
        StringBuilder encodedParams = new StringBuilder();
        try {
            for (Map.Entry<String, String> entry : params.entrySet()) {
                encodedParams.append(URLEncoder.encode(entry.getKey(), paramsEncoding));
                encodedParams.append('=');
                encodedParams.append(URLEncoder.encode(entry.getValue(), paramsEncoding));
                encodedParams.append('&');
            }
            return encodedParams.toString().getBytes(paramsEncoding);
        } catch (UnsupportedEncodingException uee) {
            throw new RuntimeException("Encoding not supported: " + paramsEncoding, uee);
        }
    }
1102999
protected void executePutRequest(URI uri, Object obj)
    {
        executePutRequest(uri, obj, null, null);
    }
453394
public Optional<Response> POST(String partialUrl, Object payload)
    {    
        URI uri = buildUri(partialUrl);   
        return executePostRequest(uri, payload);
    }
172233
public function request($uri,array $param, $state)
    {

        /** @var CheckoutApi_Lib_RespondObj $respond */
        $respond = CheckoutApi_Lib_Factory::getSingletonInstance('CheckoutApi_Lib_RespondObj');
        $this->setConfig($param);

        if(!isset($param['postedParam'])) {

            $param['postedParam'] = array();
        }
        $param['rawpostedParam'] = $param['postedParam'];
        $param['postedParam'] = $this->getParser()->preparePosted($param['postedParam']);

        $respondArray = null;

        if($state){
            $headers = $this->initHeader();
            $param['headers'] = $headers;

            /** @var CheckoutApi_Client_Adapter_Abstract $adapter */
            $adapter =  $this->getAdapter($this->getProcessType(),array('uri'=>$uri,'config'=>$param));

            if($adapter){
                $adapter->connect();
                $respondString = $adapter->request()->getRespond();
                $statusResponse = $adapter->getResourceInfo();
                $this->getParser()->setResourceInfo($statusResponse);
                $respond = $this->getParser()->parseToObj($respondString);

                if($respond && isset($respond['errors'])  && $respond->hasErrors()  ) {

                    /** @var CheckoutApi_Lib_ExceptionState  $exceptionStateObj */
                    $exceptionStateObj = $respond->getExceptionState();
                    $errors = $respond->getErrors()->toArray();
                    $exceptionStateObj->flushState();

                    foreach( $errors as $error) {
                        $this->throwException($error, $respond->getErrors()->toArray());
                    }
                }elseif( $respond && isset($respond['errorCode']) && $respond->hasErrorCode()) {
                    /** @var CheckoutApi_Lib_ExceptionState  $exceptionStateObj */
                    $exceptionStateObj = $respond->getExceptionState();

                    $this->throwException($respond->getMessage(),$respond->toArray() );

                }elseif($respond && $respond->getHttpStatus()!='200') {
                    $this->throwException('Gateway is temporary down',$param );
                }

                $adapter->close();
            }

        }

        return $respond;
    }
988874
public String doPost(String url, String body) throws IOException {
        HttpPost httpPost = new HttpPost(getWsapiUrl() + url);
        httpPost.setEntity(new StringEntity(body, "utf-8"));
        return doRequest(httpPost);
    }
292580
function GET(uri, params) {
	const reqUrl = `${uri}${url.format({ query: params })}`;

	log(`request URL: ${reqUrl}`);

	return fetch(reqUrl)
		.then(function handleGetRequest(res) {
			const status = res.status;
			const statusText = res.statusText;

			log(`status code: ${status}`);
			log(`status text: ${statusText}`);

			if (status !== 200) {
				const err = new Error(`Request failed: ${statusText}`);

				err.status = status;

				throw err;
			}

			return res.json();
		})
		.then(data => {
			const posts = data.posts;

			log(`${posts.length} posts were fetched`);

			return posts;
		})
		.catch(err => {
			log('catched err: ', err);

			throw err;
		});
}
241850
public static Post post(String uri, String content) {
        return post(uri, content.getBytes(), CONNECTION_TIMEOUT, READ_TIMEOUT);
    }
446944
public function post($uri, $parameters=array(), $headers=array(), $rawencoding=null)
    {
        return $this->request($uri, 'POST', $parameters, $headers, $rawencoding);
    }
1153313
public static String postResponseAsString(String uri, Header header,
            HttpEntity httpEntity) {
        HttpPost httpPost = new HttpPost(uri);
        httpPost.setHeader(header);
        httpPost.setEntity(httpEntity);
        return request(httpPost);
    }
978537
public RequestBody buildRequestBodyFormEncoding(Map<String, Object> formParams) {
        FormEncodingBuilder formBuilder  = new FormEncodingBuilder();
        for (Entry<String, Object> param : formParams.entrySet()) {
            formBuilder.add(param.getKey(), parameterToString(param.getValue()));
        }
        return formBuilder.build();
    }
439999
def post_request(url, params)
      begin
        resource_url = "#{@base_uri}#{url}?access_token=#{@access_token}"
        response = RestClient.post resource_url, params.to_json, {content_type: :json, accept: :json}
        result = JSON.parse(response, object_class: OpenStruct)
        return result
      rescue => e
        return JSON.parse(e.response, object_class: OpenStruct)
      end
    end
41714
private UriTuple parseUriTuple(String uri, Map<String, String[]> params) throws UnsupportedEncodingException {

		String requestUri = null;
		String queryString = "";  // default
		
		final int queryStringBegin = uri.indexOf("?");
		if (queryStringBegin == -1) {
			// Simple case -- no querystring
			requestUri = uri;
		} else {
			// Complex case -- uri+querystring
			requestUri = uri.substring(0, queryStringBegin);
			queryString = uri.substring(queryStringBegin);  // will already contain the '?' character
		}
		
		// Inject requestUri params
		for (Map.Entry<String, String[]> y : params.entrySet()) {
			final String token = "{" + y.getKey() + "}";
			final String[] values = y.getValue();
			switch (values.length) {
				case 0:
					// Strange -- I guess we omit it?
					while(requestUri.contains(token)) {
						// Don't use String.replaceAll b/c token looks like an illegal regex
						requestUri = requestUri.replace(token, "");
					}
					break;
				case 1:
					// This is healthy & normal
					final String inject = URLEncoder.encode(values[0], "UTF-8");
					while(requestUri.contains(token)) {
						// Don't use String.replaceAll b/c token looks like an illegal regex
						requestUri = requestUri.replace(token, inject);
					}
					break;
				default:
					// OOPS! --  can't have more than 1 value for a requestUri token
					final String msg = "Can't support multiple values for non-querystring URI token:  " + token;
					throw new IllegalArgumentException(msg);
			}
		}
		
		// Inject queryString params
		for (Map.Entry<String, String[]> y : params.entrySet()) {
			final String paramName = y.getKey();
			final String token = "{" + paramName + "}";
			if (queryString.contains(token)) {
				final StringBuilder value = new StringBuilder();
				for (String s : y.getValue()) {
					final String inject = URLEncoder.encode(s, "UTF-8");
					value.append(value.length() != 0 ? "&" : "");
					value.append(paramName).append("=").append(inject);
				}
				queryString = queryString.replace(token, value);
			}
		}
		
		// Split into contextName+uri
		final int contextSeparatorPos = requestUri.indexOf("/", 1);  // A valid input starts with a slash, followed by the contextName
		final String contextName = requestUri.substring(0, contextSeparatorPos);  // Includes leading '/'
		requestUri = requestUri.substring(contextSeparatorPos);  // Includes leading '/'

		return new UriTuple(contextName, requestUri + queryString);
		
	}
846641
private static JSONObject doPostRequest(HttpPost httpPost, HashMap<String, String> params) throws JSONException {
    	JSONObject json = null;
        HttpClient postClient = HttpClientBuilder.create().build();
        HttpResponse response;
        
        try {
            response = postClient.execute(httpPost);
            
            if(response.getStatusLine().getStatusCode() == 200) {
                HttpEntity entity = response.getEntity();
                
                if (entity != null) {
                    InputStream instream = entity.getContent();  
                    String result = convertStreamToString(instream);
                    instream.close();
                    
                    json = new JSONObject(result);
                }
            } else {
            	json = UpworkRestClient.genError(response);
            }
        } catch (ClientProtocolException e) {
            json = UpworkRestClient.genError(HTTP_RESPONSE_503, "Exception: ClientProtocolException");
        } catch (IOException e) {
            json = UpworkRestClient.genError(HTTP_RESPONSE_503, "Exception: IOException");
        } catch (JSONException e) {
            json = UpworkRestClient.genError(HTTP_RESPONSE_503, "Exception: JSONException");  
        } catch (Exception e) {
            json = UpworkRestClient.genError(HTTP_RESPONSE_503, "Exception: Exception " + e.toString());
        } finally {
            httpPost.abort();
        }
        
        return json;
    }