Skip to content
This repository has been archived by the owner on Oct 20, 2020. It is now read-only.

Latest commit

 

History

History
33 lines (21 loc) · 1.11 KB

sync-put.md

File metadata and controls

33 lines (21 loc) · 1.11 KB

AsyncHttpClient Example PUT

Example PUT

	SyncHttpClient<JsonElement> client = new SyncHttpClient<JsonElement>("http://example.com");
	JsonElement response = client.put("api/v1/", new JsonResponseHandler());

Example PUT - Single Entity

	SyncHttpClient<JsonElement> client = new SyncHttpClient<JsonElement>("http://example.com");

	RequestBody putBody = RequestBody.create(MediaType.parse("application/json"), "{\"test\":\"hello world\"}");

	JsonElement response = client.put("api/v1/", putBody, new JsonResponseHandler());

Example PUT - Multiple Entity + file

	SyncHttpClient<JsonElement> client = new SyncHttpClient<JsonElement>("http://example.com");

	List<NameValuePair> params = new ArrayList<>();
	params.add(new NameValuePair("key", "value"));

	Headers headers = Headers.of("Header", "value");

	RequestBody putBody = new MultipartBody.Builder().addFormDataPart("test", "test.json", RequestBody.create(MediaType.parse("application/json"), "{\"test\":\"hello world\"}"));

	JsonElement response = client.put("api/v1/", params, putBody, headers, new JsonResponseHandler());