Skip to main content
POST
/
users
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
import org.json.JSONObject;

public class MDX_RealTime {
	private String BaseUrl, ClientId, ApiKey;

	public MDX_RealTime(String BaseUrl, String ClientId, String ApiKey) {
		this.BaseUrl = BaseUrl;
		this.ClientId = ClientId;
		this.ApiKey = ApiKey;
	}

	public static void main(String[] args) throws Exception {
		String base_url = "https://int-live.moneydesktop.com";
		String client_id = ":client_id";
		String api_key = ":api_key";

		MDX_RealTime mdx = new MDX_RealTime(base_url, client_id, api_key);

		/// Setup User Create json object
		String user_id = "U-39XBF7";
		JSONObject user = new JSONObject();
		JSONObject fields = new JSONObject();
		fields.put("id", user_id);
		user.put("user", fields);

		mdx.CreateUser(user);
	}		

	public void CreateUser(JSONObject user) {
		try {
			String uri = BaseUrl + "/" + ClientId + "/users.json";
			URL url = new URL(uri);
			
			HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
			con.setRequestMethod("POST");
			con.setRequestProperty("Accept", "application/vnd.moneydesktop.mdx.v5+json");
			con.setRequestProperty("Content-Type", "application/vnd.moneydesktop.mdx.v5+json");
			con.setRequestProperty("MD-API-KEY", ApiKey);
			con.setDoOutput(true);

			OutputStream out = con.getOutputStream();
			out.write(user.toString().getBytes("UTF-8"));
			out.close();

			BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
			String inputLine;
			StringBuffer response = new StringBuffer();
			while ((inputLine = in.readLine()) != null) {
				response.append(inputLine);
			}
			in.close();
			con.disconnect();

			System.out.println(response.toString());
		} catch (Exception e) {
			System.out.println(e);
		}
	}
}
{
   "user": {
      "id": "U-39XBF7",
      "birthdate": "1959-07-17",
      "gender": "MALE",
      "first_name": "John",
      "guid": "USR-c4321d57a-9ae4-1fe3-6c4e-96a84fb92b50",
      "last_name": "Smith",
      "metadata": "Additional Information",
      "credit_score": 718,
      "email": "example@example.com",
      "phone": "(505) 555-1234",
      "zip_code": "87101",
      "is_disabled": false,
      "logged_in_at": null
   }
}

Body Parameters

birthdate
string
credit_score
string
email
string
first_name
string
gender
string
id
string
required
is_disabled
string
last_name
string
metadata
string
phone
string
zip_code
string
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
import org.json.JSONObject;

public class MDX_RealTime {
	private String BaseUrl, ClientId, ApiKey;

	public MDX_RealTime(String BaseUrl, String ClientId, String ApiKey) {
		this.BaseUrl = BaseUrl;
		this.ClientId = ClientId;
		this.ApiKey = ApiKey;
	}

	public static void main(String[] args) throws Exception {
		String base_url = "https://int-live.moneydesktop.com";
		String client_id = ":client_id";
		String api_key = ":api_key";

		MDX_RealTime mdx = new MDX_RealTime(base_url, client_id, api_key);

		/// Setup User Create json object
		String user_id = "U-39XBF7";
		JSONObject user = new JSONObject();
		JSONObject fields = new JSONObject();
		fields.put("id", user_id);
		user.put("user", fields);

		mdx.CreateUser(user);
	}		

	public void CreateUser(JSONObject user) {
		try {
			String uri = BaseUrl + "/" + ClientId + "/users.json";
			URL url = new URL(uri);
			
			HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
			con.setRequestMethod("POST");
			con.setRequestProperty("Accept", "application/vnd.moneydesktop.mdx.v5+json");
			con.setRequestProperty("Content-Type", "application/vnd.moneydesktop.mdx.v5+json");
			con.setRequestProperty("MD-API-KEY", ApiKey);
			con.setDoOutput(true);

			OutputStream out = con.getOutputStream();
			out.write(user.toString().getBytes("UTF-8"));
			out.close();

			BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
			String inputLine;
			StringBuffer response = new StringBuffer();
			while ((inputLine = in.readLine()) != null) {
				response.append(inputLine);
			}
			in.close();
			con.disconnect();

			System.out.println(response.toString());
		} catch (Exception e) {
			System.out.println(e);
		}
	}
}
{
   "user": {
      "id": "U-39XBF7",
      "birthdate": "1959-07-17",
      "gender": "MALE",
      "first_name": "John",
      "guid": "USR-c4321d57a-9ae4-1fe3-6c4e-96a84fb92b50",
      "last_name": "Smith",
      "metadata": "Additional Information",
      "credit_score": 718,
      "email": "example@example.com",
      "phone": "(505) 555-1234",
      "zip_code": "87101",
      "is_disabled": false,
      "logged_in_at": null
   }
}