I’m not a Java expert, however there seems to be a red flag to me with httpPost.setEntity(new UrlEncodedFormEntity(nameValuePair)); as mentioned before it should be a JSON, not a url encoded form.
In the end you should be passing something like { “action”: “string”, “user_info”: { “email”: “string”, “type”: “integer”, “first_name”: “string”, “last_name”: “string” } } in the body of the request
take a look at https://stackoverflow.com/questions/43690673/send-json-as-post Your code would look something like
JsonObject payload = new JsonObject();
JsonObject user_info = new JsonObject();
payload.addProperty(“action”, “create”);
user_info.addProperty(“email”,“albert.charles@medrishealth.com”);
user_info.addProperty(“type”, 3); //integer data type
user_info.addProperty(“first_name”, “Albert”);
user_info.addProperty(“last_name”, “Charles”);
//password is only used if action is autocreate
payload.addProperty(“user_info”, user_info); //not sure if this is really allowed, however user_info an object
RequestBody requestBody = RequestBody.create(jsonMediaType, new Gson().toJson(payload));
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(“http://api.zoom.us/v2/users”)
.post(requestBody)
.addHeader(“content-type”, “application/json”)
.build();
Response response = client.newCall(request).execute();
// this is the response of the post request
String res = response.body().string();
// you can get the response as json like this
JsonObject responseJson = new Gson().fromJson(res, JsonObject.class);