Code example for UrlEncodedFormEntity

0
			formparams.add(new BasicNameValuePair("name", "RALPH")); 
			formparams.add(new BasicNameValuePair("firstName", "firstName")); 
			formparams.add(new BasicNameValuePair("age", "1")); 
			formparams.add(new BasicNameValuePair("email", "invalidEmail")); 
 
			UrlEncodedFormEntity postEntity = new UrlEncodedFormEntity(formparams, "UTF-8"); 
 
			post.setEntity(postEntity); 
 
			response = client.execute(post); 
			HttpEntity entity = response.getEntity(); 
			assertThat(entity).isNotNull(); 
			String responseString = EntityUtils.toString(entity); 
 
			ObjectMapper mapper = new ObjectMapper(); 
			Map<String, Object> rootAsMap = mapper.readValue(responseString, Map.class); 
			assertThat(rootAsMap).hasSize(5); 
			assertThat(rootAsMap.get("method")).isEqualTo(method); 
			assertThat(rootAsMap.get("type")).isEqualTo("rpc"); 
			assertThat(rootAsMap.get("action")).isEqualTo("infoService"); 
Stop searching for code, let great code find you!  Add Codota to your java IDE