/*
POST request to webServiceURL/version/devices/{deviceLibraryIdentifier}/registrations/{passTypeIdentifier}/{serialNumber}
490244
@Post("json")
	public final void registerDeviceRequest(final Representation entity) {
		Request request = getRequest();
		Map<String, Object> requestAttributes = request.getAttributes();
		String deviceLibraryIdentifier = (String) requestAttributes.get("deviceLibraryIdentifier");
		String passTypeIdentifier = (String) requestAttributes.get("passTypeIdentifier");
		String serialNumber = (String) requestAttributes.get("serialNumber");
		String authString = request.getChallengeResponse().getRawValue();
		Status responseStatus;
		try {
			String jsonPushToken = entity.getText();
			PKPushToken pkPushToken = jsonObjectMapper.readValue(jsonPushToken, PKPushToken.class);

			LOGGER.debug("registerDeviceRequest - deviceLibraryIdentifier: {}", deviceLibraryIdentifier);
			LOGGER.debug("registerDeviceRequest - passTypeIdentifier: {}", passTypeIdentifier);
			LOGGER.debug("registerDeviceRequest - serialNumber: {}", serialNumber);
			LOGGER.debug("registerDeviceRequest - authString: {}", authString);
			LOGGER.debug("registerDeviceRequest - jsonPushToken: {}", jsonPushToken);
			LOGGER.debug("registerDeviceRequest - pkPushToken: {}", pkPushToken);
			responseStatus = handleRegisterDeviceRequest(deviceLibraryIdentifier, passTypeIdentifier, serialNumber, authString, pkPushToken);
		} catch (PKAuthTokenNotValidException e) {
			responseStatus = Status.CLIENT_ERROR_UNAUTHORIZED;
		} catch (IOException e) {
			responseStatus = Status.SERVER_ERROR_INTERNAL;
		}
		setStatusIntoResponse(responseStatus, getResponse());
	}
501134
private void addPostParams(final Request request) {
        if (certificateData != null) {
            request.addPostParam("CertificateData", certificateData);
        }

        if (friendlyName != null) {
            request.addPostParam("FriendlyName", friendlyName);
        }

        if (deviceSid != null) {
            request.addPostParam("DeviceSid", deviceSid);
        }
    }
510453
public ApiResponse<DeviceStatus> putDeviceStatusWithHttpInfo(String deviceId, DeviceStatusPut body) throws ApiException {
        com.squareup.okhttp.Call call = putDeviceStatusValidateBeforeCall(deviceId, body, null, null);
        Type localVarReturnType = new TypeToken<DeviceStatus>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }
553546
@Override
    public final <RQ, RS> Maybe<Response<RS>> post(String resource, RQ rq, Type type)
            throws RestEndpointIOException {
        HttpPost post = new HttpPost(spliceUrl(resource));
        Serializer serializer = getSupportedSerializer(rq);
        ByteArrayEntity httpEntity = new ByteArrayEntity(serializer.serialize(rq),
                ContentType.create(serializer.getMimeType()));
        post.setEntity(httpEntity);
        return executeInternal(post, new TypeConverterCallback<RS>(serializers, type));
    }
386676
@Transactional
  @PostMapping(
      value = "/{entityTypeId}",
      headers = "Content-Type=application/x-www-form-urlencoded")
  public void createFromFormPost(
      @PathVariable("entityTypeId") String entityTypeId,
      HttpServletRequest request,
      HttpServletResponse response) {
    Map<String, Object> paramMap = new HashMap<>();
    for (String param : request.getParameterMap().keySet()) {
      String[] values = request.getParameterValues(param);
      String value = values != null ? StringUtils.join(values, ',') : null;
      if (StringUtils.isNotBlank(value)) {
        paramMap.put(param, value);
      }
    }

    createInternal(entityTypeId, paramMap, response);
  }
241815
public void accessRestriction_u2f_id_validate_POST(Long id, String clientData, String registrationData) throws IOException {
		String qPath = "/me/accessRestriction/u2f/{id}/validate";
		StringBuilder sb = path(qPath, id);
		HashMap<String, Object>o = new HashMap<String, Object>();
		addBody(o, "clientData", clientData);
		addBody(o, "registrationData", registrationData);
		exec(qPath, "POST", sb.toString(), o);
	}
370205
func (sp *ServiceProvider) MakePostAuthenticationRequest(relayState string) ([]byte, error) {
	req, err := sp.MakeAuthenticationRequest(sp.GetSSOBindingLocation(HTTPPostBinding))
	if err != nil {
		return nil, err
	}
	return req.Post(relayState), nil
}
188593
@Override
  public void sendAuthAnswer(AppAnswerEvent appAnswerEvent) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
    send(null, appAnswerEvent);
  }
585658
private <TResponse> TResponse callServiceOwnerPostApi(
            String path, Object requestBody, Class<TResponse> responseClass) throws AuthleteApiException
    {
        return callServiceOwnerPostApi(path, (Map<String, String>)null, requestBody, responseClass);
    }
1180832
public String processHTTPAPIRequest(
			String urlString,
			JSONObject request,
			GenericUser authenticationUser,
			String requestType, 
			String[] requestParameters,
			String... requestHedaers) throws CertificateException, IOException, JSONException {
		
		log.debug("API request: " + request.toString(4));
		String jsonRequest = request.toString();
		
		HttpURLConnection ucon = null;
		
		if("POST".equals(requestType)) {
			
			URL url = new URL(urlString);		
			log.debug("API request: " + url);
			
			ucon = (HttpURLConnection) url.openConnection();

			ucon.setRequestMethod("POST");
			ucon.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
						
			setRequestHeaders(ucon, authenticationUser, requestHedaers);
				
			for(int i = 0 ; i < requestParameters.length; i = i + 2) {
				ucon.setRequestProperty(getReferenceService().namespaceString(requestParameters[i]), getReferenceService().namespaceString(requestParameters[i+1]));
			}
			
			ucon.setUseCaches (false);
			ucon.setDoInput(true);
			ucon.setDoOutput(true);

		    //Send request
			String encodedPostRequest = "json=" + URLEncoder.encode(jsonRequest, "UTF-8");
			ucon.setRequestProperty("Content-Length", Integer.toString(encodedPostRequest.getBytes().length));
		    DataOutputStream wr = new DataOutputStream (ucon.getOutputStream ());
			wr.writeBytes(encodedPostRequest);
		    wr.flush ();
		    wr.close ();
		}
		else if ("GET".equals(requestType)) {
			log.debug("API request: " + request.toString());
			
			
			StringBuilder builder = new StringBuilder();
			builder.append(urlString + "?json=" + URLEncoder.encode(request.toString(), "UTF-8").replaceAll("\"", "%22"));
			for(int i = 0 ; i < requestParameters.length; i = i + 2) {
				builder.append("&" + getReferenceService().namespaceString(requestParameters[i]) + "=" + getReferenceService().namespaceString(requestParameters[i+1]));
			}
			
			URL url = new URL(builder.toString());		
			log.debug("API request: " + url);

			ucon = (HttpURLConnection) url.openConnection();
			setRequestHeaders(ucon, authenticationUser, requestHedaers);
			
			ucon.setConnectTimeout(5000);
			ucon.setFollowRedirects(true);
			ucon.setDoOutput(true);
		}
		else {
			throw new IllegalArgumentException("Only POST and GET API requests are supported at this stage");
		}

		
		//Obtain the response
		StringBuilder responseBuilder = new StringBuilder();
		try{			
			InputStream inputStream = ucon.getInputStream();
			
			BufferedReader in = new BufferedReader(new InputStreamReader(inputStream));
			String pre = null;                       
			while ((pre = in.readLine()) != null){
				responseBuilder.append(pre);
				responseBuilder.append("\n");
			}
			in.close();
		}
		catch (IOException e) {
			//on error codes we should not fail but just capture the response code
			log.debug("Genarating the API call response caused: ", e);
		}
		String response = responseBuilder.toString();
		
		log.debug("The generated API call response: " + response);
		
		getScenarioGlobals().setAttribute(LAST_SCENARIO_HTTP_RESPONSE_CODE_KEY, ucon.getResponseCode());
		
		return response;
	}
821046
private void addPostParams(final Request request) {
        if (hostedNumberOrderSids != null) {
            for (String prop : hostedNumberOrderSids) {
                request.addPostParam("HostedNumberOrderSids", prop);
            }
        }

        if (addressSid != null) {
            request.addPostParam("AddressSid", addressSid);
        }

        if (email != null) {
            request.addPostParam("Email", email);
        }

        if (contactTitle != null) {
            request.addPostParam("ContactTitle", contactTitle);
        }

        if (contactPhoneNumber != null) {
            request.addPostParam("ContactPhoneNumber", contactPhoneNumber);
        }

        if (ccEmails != null) {
            for (String prop : ccEmails) {
                request.addPostParam("CcEmails", prop);
            }
        }
    }
1308203
private void addPostParams(final Request request) {
        if (identity != null) {
            request.addPostParam("Identity", identity);
        }

        if (userAddress != null) {
            request.addPostParam("UserAddress", userAddress);
        }

        if (attributes != null) {
            request.addPostParam("Attributes", attributes);
        }

        if (twilioAddress != null) {
            request.addPostParam("TwilioAddress", twilioAddress);
        }

        if (dateCreated != null) {
            request.addPostParam("DateCreated", dateCreated.toString());
        }

        if (dateUpdated != null) {
            request.addPostParam("DateUpdated", dateUpdated.toString());
        }
    }
618787
public void postProgrammaticAuthenticate(final HttpServletRequest req, final HttpServletResponse resp, final AuthenticationResult authResult,
                                             final boolean alwaysSetCallerSubject, final boolean addSSOCookie) {
        if (System.getSecurityManager() == null) {
            setSubjectAndCookies(req, resp, authResult, alwaysSetCallerSubject, addSSOCookie);
        } else {
            AccessController.doPrivileged(new PrivilegedAction<Object>() {

                @Override
                public Object run() {
                    setSubjectAndCookies(req, resp, authResult, alwaysSetCallerSubject, addSSOCookie);
                    return null;
                }
            });
        }
    }
604887
private void addPostParams(final Request request) {
        if (friendlyName != null) {
            request.addPostParam("FriendlyName", friendlyName);
        }

        if (uniqueName != null) {
            request.addPostParam("UniqueName", uniqueName);
        }

        if (email != null) {
            request.addPostParam("Email", email);
        }

        if (ccEmails != null) {
            for (String prop : ccEmails) {
                request.addPostParam("CcEmails", prop);
            }
        }

        if (status != null) {
            request.addPostParam("Status", status.toString());
        }

        if (verificationCode != null) {
            request.addPostParam("VerificationCode", verificationCode);
        }

        if (verificationType != null) {
            request.addPostParam("VerificationType", verificationType.toString());
        }

        if (verificationDocumentSid != null) {
            request.addPostParam("VerificationDocumentSid", verificationDocumentSid);
        }

        if (extension != null) {
            request.addPostParam("Extension", extension);
        }

        if (callDelay != null) {
            request.addPostParam("CallDelay", callDelay.toString());
        }
    }
164373
private void addPostParams(final Request request) {
        if (phoneNumber != null) {
            request.addPostParam("PhoneNumber", phoneNumber.toString());
        }

        if (apiVersion != null) {
            request.addPostParam("ApiVersion", apiVersion);
        }

        if (friendlyName != null) {
            request.addPostParam("FriendlyName", friendlyName);
        }

        if (smsApplicationSid != null) {
            request.addPostParam("SmsApplicationSid", smsApplicationSid);
        }

        if (smsFallbackMethod != null) {
            request.addPostParam("SmsFallbackMethod", smsFallbackMethod.toString());
        }

        if (smsFallbackUrl != null) {
            request.addPostParam("SmsFallbackUrl", smsFallbackUrl.toString());
        }

        if (smsMethod != null) {
            request.addPostParam("SmsMethod", smsMethod.toString());
        }

        if (smsUrl != null) {
            request.addPostParam("SmsUrl", smsUrl.toString());
        }

        if (statusCallback != null) {
            request.addPostParam("StatusCallback", statusCallback.toString());
        }

        if (statusCallbackMethod != null) {
            request.addPostParam("StatusCallbackMethod", statusCallbackMethod.toString());
        }

        if (voiceApplicationSid != null) {
            request.addPostParam("VoiceApplicationSid", voiceApplicationSid);
        }

        if (voiceCallerIdLookup != null) {
            request.addPostParam("VoiceCallerIdLookup", voiceCallerIdLookup.toString());
        }

        if (voiceFallbackMethod != null) {
            request.addPostParam("VoiceFallbackMethod", voiceFallbackMethod.toString());
        }

        if (voiceFallbackUrl != null) {
            request.addPostParam("VoiceFallbackUrl", voiceFallbackUrl.toString());
        }

        if (voiceMethod != null) {
            request.addPostParam("VoiceMethod", voiceMethod.toString());
        }

        if (voiceUrl != null) {
            request.addPostParam("VoiceUrl", voiceUrl.toString());
        }

        if (identitySid != null) {
            request.addPostParam("IdentitySid", identitySid);
        }

        if (addressSid != null) {
            request.addPostParam("AddressSid", addressSid);
        }
    }
977663
private void addPostParams(final Request request) {
        if (identifier != null) {
            request.addPostParam("Identifier", identifier);
        }

        if (friendlyName != null) {
            request.addPostParam("FriendlyName", friendlyName);
        }

        if (proxyIdentifier != null) {
            request.addPostParam("ProxyIdentifier", proxyIdentifier);
        }

        if (proxyIdentifierSid != null) {
            request.addPostParam("ProxyIdentifierSid", proxyIdentifierSid);
        }
    }
866256
function(params, callback) {
                var keyId;

                if (params) {
                    if (params.keyId != 'undefined') {
                        keyId = params.keyId;
                    }
                }

                var httpRequestParams = {
                    url: SERVICE_ADDRESSES.SSO_ADDRESS + SERVICES_PATH.SSO_GET_KEY + keyId,
                    method: 'GET',
                    headers: {
                        'Authorization': 'Bearer ' + token
                    }
                };

                httpRequest(httpRequestParams, function(result) {
                    if (!result.hasError) {
                        try {
                            var response = JSON.parse(result.result.responseText);
                        }
                        catch (e) {
                            console.log(e);
                        }

                        callback && callback({
                            hasError: false,
                            secretKey: response.secretKey
                        });
                    }
                    else {
                        callback && callback({
                            hasError: true,
                            code: result.errorCode,
                            message: result.errorMessage
                        });

                        fireEvent('error', {
                            code: result.errorCode,
                            message: result.errorMessage,
                            error: result
                        });
                    }
                });
            }