NAV

Custom Data Field(Last Updated : 01/04/2017)

You can create and use custom data fields for collecting extra information from subscribers. First, you will use PUT Custom Data Field to create a new field. Then, use PUT and POST Subscription to add your custom data. You can create up to 10 different custom data fields.

Methods

PUT /rest/v1/{user_name}/customdata
GET /rest/v1/{user_name}/customdata
GET /rest/v1/{user_name}/customdata/{customdata_id}
POST /rest/v1/{user_name}/customdata/{customdata_id}
DELETE /rest/v1/{user_name}/customdata/{customdata_id}

PUT Custom Data Field

Set up a custom data field by providing the parameters provided below. You can set up six types of custom data fields: Text Field, Radio buttons, Drop-down list, Date/Time, Text Area, and Number. You may only have 10 custom data fields by default, please contact support if you require more custom data fields.

Resource Information

Response Formats JSON
Allowed Methods PUT
URL http://api.trumpia.com/rest/v1/{user_name}/customdata
{user_name} Your account username (this can be found in the Account Settings page after logging in.)

Header Parameters

* required parameters
Parameter Description
Content-Type * application/json
X-Apikey * Your API key (This can be found in the API Settings page after logging in.)

Example value: 123456789abc1011

Body Parameters

* required parameters
Parameter Description
name * The name for the specific Custom Data Field. A name can only be 3-30 characters in length. This is case-insensitive but must contain alphanumeric characters and only a few special characters such as (, ), /, -, and space.

Example value: Birth-Day(February)
input_type * The input type for the specific Custom Data Field.
Value Description
1 Text Field
3 Radio Buttons
4 Drop-down List
5 Date & Time
6 Text Area
7 Number
required * You can make a custom data field required or not for a new Online Signup Page subscriber. Custom fields will still be optional if you update the data via PUT/POST Subscription.
Value Description
1 Required
2 Optional
options * These are other setting options for the Custom Data Field. Each type contains different options. All parameters are required for their specific data type. See Options Object table below.

> Options Object

* required parameters
Data Type Parameter Description
Text Field width * This is the UI option for the Online Signup Page. Width value should be 1-239 pixels and should only be a numeric value.
  max_length * The maximum allowed length of the inputted text. Max_length value should be 1-4000 and should only be a numeric value.
Radio Button values * Valid values for this custom data field. You can register up to 10 values.
Drop-down List values * Valid values for this custom data. You can register up to 100 different values.
Date & Time time * You can set 'Date Only' or 'Date & time'.
Value Description
1 Date Only
2 Date & Time
Text Area width * This is the UI option for Online Signup Page. Width value should be 1-239 pixels and should be a numeric value.
  rows * This is the UI option for Online Signup Page. Width value should be 1-9 rows and should be a numeric value.
Number min * Minimum number value. Min value should be numerical over 0.
  max * Maximum number value. Max value should be numerical under 9,999,999.
  default * Default number value.

Code sample for PUT Custom Data Field

"Request Example: Text Field Case
PUT http://api.trumpia.com/rest/v1/{user_name}/customdata"
{
  "name" : "School",
  "input_type" : 1,
  "required" : 1,
  "options" :
  {
    "width" : 100,
    "max_length" : 300
  }
}

"Request Example: Radio Button Case
PUT http://api.trumpia.com/rest/v1/{user_name}/customdata"
{
  "name" : "Favorite Brand",
  "input_type" : 3,
  "required" : 2,
  "options" :
  {
    "values" :
    [
      "Jaguar", "BMW", "KIA"
    ]
  }
}

"Request Example: Drop-down List Case
PUT http://api.trumpia.com/rest/v1/{user_name}/customdata"
{
  "name" : "Car Brand",
  "input_type" : 4,
  "required" : 1,
  "options" :
  {
    "values" :
    [
      "Jaguar", "BMW", "KIA"
    ]
  }
}

"Request Example: Date & Time Case
PUT http://api.trumpia.com/rest/v1/{user_name}/customdata"
{
  "name" : "Birthday",
  "input_type" : 5,
  "required" : 1,
  "options" :
  {
    "time" : 1
  }
}

"Request Example: Text Area Case
PUT http://api.trumpia.com/rest/v1/{user_name}/customdata"
{
  "name" : "Self Introduce",
  "input_type" : 6,
  "required" : 2,
  "options" :
  {
    "width" : 100,
    "rows" : 5
  }
}

"Request Example: Number Case
PUT http://api.trumpia.com/rest/v1/{user_name}/customdata"
{
  "name" : "Age",
  "input_type" : 7,
  "required" : 1,
  "options" :
  {
    "min" : 17,
    "max" : 100,
    "default" : 20
  }
}

"Response Example:"
{
  "request_id" : "1234561234567asdf123"
}


<?
	// PUT Custom Data Field - Create a custom data field.
	include "request_rest.php";

	$request_url = "http://api.trumpia.com/rest/v1/{user_name}/customdata";

	$request_data = array(
							"name" => "customdataname",
							"input_type" => 4,
							"required" => 1,
							"options" => array("apple", "banana", "tomato", "melon")
						);

	$request_rest = new RestRequest();

	$request_rest->setRequestURL($request_url);
	$request_rest->setAPIKey("{api_key}");
	$request_rest->setRequestBody(json_encode($request_data));
	$request_rest->setMethod("PUT");
	$result = $request_rest->execute();

	$response_status = $result[0];
	$json_response_data = $result[1];

	if ($response_status == "200") {	//success
		$response_data = json_decode($json_response_data);
		echo "request_id : " . $response_data->request_id . "<br>";
	} else {
		echo $response_status ." - connection failure";
	}
?>


// PUT Custom Data Field - Create a custom data field.
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="org.json.simple.JSONArray" %>
<%@ page import="org.json.simple.JSONObject" %>
<%@ page import="java.io.BufferedReader" %>
<%@ page import="java.io.IOException" %>
<%@ page import="java.io.InputStreamReader" %>
<%@ page import="java.io.OutputStream" %>
<%@ page import="java.io.OutputStreamWriter" %>
<%@ page import="java.io.Writer" %>
<%@ page import="java.net.HttpURLConnection" %>
<%@ page import="java.net.URL" %>
<html>
<title>CustomdataPut Sample Code</title>
<body>

<%
  String username = "username";
	String name = "customdataname";
	int inputType = 5;
	int required = 1;
	JSONObject options = new JSONObject();
	options.put("time", 1);

	JSONObject customdataPut = new JSONObject();
	customdataPut.put("name", name);
	customdataPut.put("input_type", inputType);
	customdataPut.put("required", required);
	customdataPut.put("options", options);

	String urlStr = "http://api.trumpia.com/rest/v1/" + username + "/customdata";
	URL url = new URL(urlStr);
	HttpURLConnection conn = (HttpURLConnection) url.openConnection();
	conn.setRequestMethod("PUT");
	conn.setDoOutput(true);
	conn.setDoInput(true);
	conn.setUseCaches(false);
	conn.setAllowUserInteraction(false);
	conn.setRequestProperty("Content-type", "application/json");
	conn.setRequestProperty("X-Apikey", "12345aaaaa67890aaaaa");
	OutputStream outPutStream = conn.getOutputStream();
	Writer writer = new OutputStreamWriter(outPutStream, "UTF-8");
	writer.write(listPut.toJSONString());
	writer.close();
	outPutStream.close();

	if (conn.getResponseCode() != 200) {
%>
	Error : <%=conn.getResponseMessage()%>
<%
	}else{
	// Buffer the result into a string
	BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
	StringBuilder sb = new StringBuilder();
	String line;
	while ((line = rd.readLine()) != null) {
		sb.append(line);
	}
	rd.close();
	conn.disconnect();
%>
	Response : <%=sb.toString()%>
<%
	}
%>
</body>
</html>


// PUT Custom Data Field - Create a custom data field.
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;

namespace samplecode
{
    class CustomdataInfo
    {
        public string name { get; set; }
        public string input_type { get; set; }
        public string required { get; set; }
        public JObject options { get; set; }
    }
    class Result
    {
        public string request_id { get; set; }
    }
    class CustomdataPut
    {
        static void Main()
        {
            RunAsync().Wait();
        }

        static async Task RunAsync()
        {
            using (var client = new HttpClient())
            {
                var apikey = "12345aaaaa67890aaaaa";

                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Add("X-Apikey", string.Format("{0}", apikey));

                var username = "username";

                //PUT
                JObject optionsData = new JObject();
                optionsData.Add("min", 0);
                optionsData.Add("max", 100);
                optionsData.Add("default", 1);

                var info = new CustomdataInfo() { name = "customdata", input_type = "7", required = "2", options = optionsData };
                Uri postUrl = new Uri(string.Format("http://api.trumpia.com/rest/v1/{0}/customdata", username));
                var response = client.PutAsJsonAsync(postUrl, info).Result;
                if (response.IsSuccessStatusCode)
                {
                    var p = response.Content.ReadAsAsync<Result>().Result;
                    string json = JsonConvert.SerializeObject(p);
                    Console.WriteLine(json);
                }
            }
        }
    }
}

GET Custom Data Field

Look up the IDs of created custom data fields, or look up detailed information for a custom data field.

Resource Information

Response Formats JSON
Allowed Methods GET
URL http://api.trumpia.com/rest/v1/{user_name}/customdata
http://api.trumpia.com/rest/v1/{user_name}/customdata/{customdata_id}
{user_name} Your account username (this can be found in the Account Settings page after logging in.)
{customdata_id} Get information from a specific custom data field ID.

Header Parameters

* required parameters
Parameter Description
Content-Type * application/json
X-Apikey * Your API key (This can be found in the API Settings page after logging in.)

Example value: 123456789abc1011

Code sample for GET Custom Data Field

"Request Example: Get all lists of custom data fields.
GET http://api.trumpia.com/rest/v1/{user_name}/customdata"

"Request Example:"
{
  "customdata" :
  [
    {
      "customdata_id" : 987987987980,
      "name" : "school"
    },
    {
      "customdata_id" : 987987987981,
      "name" : "favorite fruit"
    },
    {
      "customdata_id" : 987987987982,
      "name" : "birthday"
    }
  ]
}

"Response Example: Get a specific custom data fields.
GET http://api.trumpia.com/rest/v1/{user_name}/customdata/{customdata_id}"

"Response Example:"
{
  "customdata_id" : 987987987980,
  "name" : "School",
  "input_type" : 1,
  "required" : 1,
  "options" :
  {
    "width" : 100,
    "max_length" : 300
  }
}


<?
	// GET Custom Data Field - Retrieve all custom data fields.
	include "request_rest.php";

	$request_url = "http://api.trumpia.com/rest/v1/{user_name}/customdata";

	$request_rest = new RestRequest();

	$request_rest->setRequestURL($request_url);
	$request_rest->setAPIKey("{api_key}");
	$request_rest->setMethod("GET");
	$result = $request_rest->execute();

	$response_status = $result[0];
	$json_response_data = $result[1];

	if ($response_status == "200") {	//success
		echo $json_response_data;
	} else {
		echo $response_status ." - connection failure";
	}
?>


<?
	// GET Custom Data Field - Retrieve a custom data field by ID.
	include "request_rest.php";

	$request_url = "http://api.trumpia.com/rest/v1/{user_name}/customdata";
	$customdata_id = "987987987980";
	$request_url =	$request_url . "/" . $customdata_id;

	$request_rest = new RestRequest();

	$request_rest->setRequestURL($request_url);
	$request_rest->setAPIKey("{api_key}");
	$request_rest->setMethod("GET");
	$result = $request_rest->execute();

	$response_status = $result[0];
	$json_response_data = $result[1];

	if ($response_status == "200") {	//success
		echo $json_response_data;
	} else {
		echo $response_status ." - connection failure";
	}
?>


// GET Custom Data Field - Retrieve all custom data fields.
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="org.json.simple.JSONArray" %>
<%@ page import="org.json.simple.JSONObject" %>
<%@ page import="java.io.BufferedReader" %>
<%@ page import="java.io.IOException" %>
<%@ page import="java.io.InputStreamReader" %>
<%@ page import="java.io.OutputStream" %>
<%@ page import="java.io.OutputStreamWriter" %>
<%@ page import="java.io.Writer" %>
<%@ page import="java.net.HttpURLConnection" %>
<%@ page import="java.net.URL" %>
<html>
<title>CustomdataGetAll Sample Code</title>
<body>

<%
	String username = "username";
	String urlStr = "http://api.trumpia.com/rest/v1/" + username + "/customdata";

	URL url = new URL(urlStr);
	HttpURLConnection conn = (HttpURLConnection) url.openConnection();
	conn.setRequestProperty("Content-type", "application/json");
	conn.setRequestProperty("X-Apikey", "12345aaaaa67890aaaaa ");

	if (conn.getResponseCode() != 200) {
%>
	Error : <%=conn.getResponseMessage()%>
<%
	}else{
	// Buffer the result into a string
	BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
	StringBuilder sb = new StringBuilder();
	String line;
	while ((line = rd.readLine()) != null) {
		sb.append(line);
	}
	rd.close();
	conn.disconnect();
%>
	Response : <%=sb.toString()%>
<%
	}
%>
</body>
</html>


// GET Custom Data Field - Retrieve a custom data field by ID.
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="org.json.simple.JSONArray" %>
<%@ page import="org.json.simple.JSONObject" %>
<%@ page import="java.io.BufferedReader" %>
<%@ page import="java.io.IOException" %>
<%@ page import="java.io.InputStreamReader" %>
<%@ page import="java.io.OutputStream" %>
<%@ page import="java.io.OutputStreamWriter" %>
<%@ page import="java.io.Writer" %>
<%@ page import="java.net.HttpURLConnection" %>
<%@ page import="java.net.URL" %>
<html>
<title>CustomdataGetById Sample Code</title>
<body>

<%
	String username = "username";
	String customdataId = "987987987980";
	String urlStr = "http://api.trumpia.com/rest/v1/" + username + "/customdata/" + customdataId;

	URL url = new URL(urlStr);
	HttpURLConnection conn = (HttpURLConnection) url.openConnection();
	conn.setRequestProperty("Content-type", "application/json");
	conn.setRequestProperty("X-Apikey", "12345aaaaa67890aaaaa ");

	if (conn.getResponseCode() != 200) {
%>
	Error : <%=conn.getResponseMessage()%>
<%
	}else{
	// Buffer the result into a string
	BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
	StringBuilder sb = new StringBuilder();
	String line;
	while ((line = rd.readLine()) != null) {
		sb.append(line);
	}
	rd.close();
	conn.disconnect();
%>
	Response : <%=sb.toString()%>
<%
	}
%>
</body>
</html>


// GET Custom Data Field - Retrieve all custom data fields.
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;

namespace samplecode
{
    class CustomdataInfo
    {
        public JArray Customdata { get; set;}
    }
    class CustomdataGet
    {
        static void Main(string[] args)
        {
            RunAsync().Wait();
        }

        static async Task RunAsync()
        {
            using (var client = new HttpClient())
            {
                var apikey = "12345aaaaa67890aaaaa";

                client.BaseAddress = new Uri("http://api.trumpia.com");
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Add("X-Apikey", string.Format("{0}", apikey));

                var username = "username";

                //GET
                HttpResponseMessage response = await client.GetAsync(string.Format("/rest/v1/{0}/customdata", username));
                if (response.IsSuccessStatusCode)
                {
                    CustomdataInfo customdataInfo = await response.Content.ReadAsAsync<CustomdataInfo>();
                    string json = JsonConvert.SerializeObject(customdataInfo);
                    Console.WriteLine(json);
                }
            }
        }
    }
}


// GET Custom Data Field - Retrieve a custom data field by ID.
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;

namespace samplecode
{
    class CustomdataInfo
    {
        public JObject result { get; set; }
    }
    class CustomdataDetailGet
    {
        static void Main()
        {
            RunAsync().Wait();
        }

        static async Task RunAsync()
        {
            using (var client = new HttpClient())
            {
                var apikey = "12345aaaaa67890aaaaa";

                client.BaseAddress = new Uri("http://api.trumpia.com");
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Add("X-Apikey", string.Format("{0}", apikey));

                var username = "username";
                var customdataId = "987987987980";

                //GET

                HttpResponseMessage response = await client.GetAsync(string.Format("/rest/v1/{0}/customdata/{1}", username, customdataId));
                if (response.IsSuccessStatusCode)
                {
                    var resultInfo = await response.Content.ReadAsStringAsync();
                    string json = JsonConvert.SerializeObject(resultInfo);
                    Console.WriteLine(json);
                }
            }
        }
    }
}

POST Custom Data Field

Update the parameters of a custom data field.

Resource Information

Response Formats JSON
Allowed Methods POST
URL http://api.trumpia.com/rest/v1/{user_name}/customdata/{customdata_id}
{user_name} Your account username (this can be found in the Account Settings page after logging in.)
{customdata_id} Edit the information for this custom data field ID.

Header Parameters

* required parameters
Parameter Description
Content-Type * application/json
X-Apikey * Your API key (This can be found in the API Settings page after logging in.)

Example value: 123456789abc1011

Body Parameters

* required parameters
Parameter Description
required You can make a custom data field required or not for a new Online Signup Page subscriber. Custom fields will still be optional if you update the data via PUT/POST Subscription.
Value Description
1 Required
2 Optional
options These are other setting options for the Custom Data Field. Each type contains different options. All parameters are required for their specific data type. See Options Object table below.

> Options Object

* required parameters
Data Type Parameter Description
Text Field width This is the UI option for the Online Signup Page. Width value should be 1-239 pixels and should only be a numeric value.
Radio Button values Valid values for this custom data field. You can register up to 10 values.
Drop-down List values Valid values for this custom data. You can register up to 100 different values.
Date & Time time You can set 'Date Only' or 'Date & time'.
Value Description
1 Date Only
2 Date & Time
Text Area width This is the UI option for Online Signup Page. Width value should be 1-239 pixels and should be a numeric value.
  rows This is the UI option for Online Signup Page. Width value should be 1-9 rows and should be a numeric value.
Number min Minimum number value. Min value should be numerical over 0.
  max Maximum number value. Max value should be numerical under 9,999,999.
  default Default number value.

Code sample for POST Custom Data Field

"Request Example: Text Field Case
POST http://api.trumpia.com/rest/v1/{user_name}/customdata/{customdata_id}"
{
  "required" : 1,
  "options" :
  {
    "width" : 100
  }
}

"Request Example: Radio Button Case
POST http://api.trumpia.com/rest/v1/{user_name}/customdata/{customdata_id}"
{
  "required" : 1,
  "options" :
  {
    "values" :
    [
      "Jaguar", "BMW", "KIA"
    ]
  }
}

"Request Example: Drop-down List Case
POST http://api.trumpia.com/rest/v1/{user_name}/customdata/{customdata_id}"
{
  "required" : 2,
  "options" :
  {
    "values" :
    [
      "Jaguar", "BMW", "KIA"
    ]
  }
}

"Request Example: Date & Time Case
POST http://api.trumpia.com/rest/v1/{user_name}/customdata/{customdata_id}"
{
  "required" : 1,
  "options" :
  {
    "time" : 1
  }
}

"Request Example: Text Area Case
POST http://api.trumpia.com/rest/v1/{user_name}/customdata/{customdata_id}"
{
  "required" : 1,
  "options" :
  {
    "width" : 200,
    "rows" : 5
  }
}

"Request Example: Number Case
POST http://api.trumpia.com/rest/v1/{user_name}/customdata/{customdata_id}"
{
  "required" : 2,
  "options" :
  {
    "min" : 17,
    "max" : 100,
    "default" : 20
  }
}

"Response Example:"
{
  "request_id" : "1234561234567asdf123"
}


<?
	// POST Custom Data Field - Update a custom data field.
	include "request_rest.php";

	$request_url = "http://api.trumpia.com/rest/v1/{user_name}/customdata";
	$customdata_id = "987987987980";
	$request_url =	$request_url . "/" . $customdata_id;

	$request_data = array(
							"required" => 2,
							"options" => array("mango", "strawberry")
						);

	$request_rest = new RestRequest();

	$request_rest->setRequestURL($request_url);
	$request_rest->setAPIKey("{api_key}");
	$request_rest->setRequestBody(json_encode($request_data));
	$request_rest->setMethod("POST");
	$result = $request_rest->execute();

	$response_status = $result[0];
	$json_response_data = $result[1];

	if ($response_status == "200") {	//success
		$response_data = json_decode($json_response_data);
		echo "request_id : " . $response_data->request_id;
	} else {

		echo $response_status ." - connection failure";
	}
?>


// POST Custom Data Field - Update a custom data field.
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="org.json.simple.JSONArray" %>
<%@ page import="org.json.simple.JSONObject" %>
<%@ page import="java.io.BufferedReader" %>
<%@ page import="java.io.IOException" %>
<%@ page import="java.io.InputStreamReader" %>
<%@ page import="java.io.OutputStream" %>
<%@ page import="java.io.OutputStreamWriter" %>
<%@ page import="java.io.Writer" %>
<%@ page import="java.net.HttpURLConnection" %>
<%@ page import="java.net.URL" %>
<html>
<title>CustomdataEdit Sample Code</title>
<body>

<%
	String username = "username";
	String customdataId = "987987987980";
	int required = 1;
	JSONObject options = new JSONObject();
	options.put("time", 1);

	JSONObject customdataDelete = new JSONObject();
	customdataDelete.put("required", required);
	customdataDelete.put("options", options);

	String urlStr = "http://api.trumpia.com/rest/v1/" + username + "/customdata/" + customdataId;
	URL url = new URL(urlStr);
	HttpURLConnection conn = (HttpURLConnection) url.openConnection();
	conn.setRequestMethod("POST");
	conn.setDoOutput(true);
	conn.setDoInput(true);
	conn.setUseCaches(false);
	conn.setAllowUserInteraction(false);
	conn.setRequestProperty("Content-type", "application/json");
	conn.setRequestProperty("X-Apikey", "12345aaaaa67890aaaaa");
	OutputStream outPutStream = conn.getOutputStream();
	Writer writer = new OutputStreamWriter(outPutStream, "UTF-8");
	writer.write(listPost.toJSONString());
	writer.close();
	outPutStream.close();

	if (conn.getResponseCode() != 200) {
%>
	Error : <%=conn.getResponseMessage()%>
<%
	}else{
	// Buffer the result into a string
	BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
	StringBuilder sb = new StringBuilder();
	String line;
	while ((line = rd.readLine()) != null) {
		sb.append(line);
	}
	rd.close();
	conn.disconnect();
%>
	Response : <%=sb.toString()%>
<%
	}
%>
</body>
</html>


// POST Custom Data Field - Update a custom data field.
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;

namespace samplecode
{
    class CustomdataInfo
    {
        public string required { get; set; }
        public JObject options { get; set; }
    }
    class Result
    {
        public string request_id { get; set; }
    }
    class CustomdataPost
    {
        static void Main()
        {
            RunAsync().Wait();
        }

        static async Task RunAsync()
        {
            using (var client = new HttpClient())
            {
                var apikey = "12345aaaaa67890aaaaa";

                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Add("X-Apikey", string.Format("{0}", apikey));

                var username = "username";
                var customdataId = "987987987980";

                //POST
                JObject optionsData = new JObject();
                optionsData.Add("min", 0);
                optionsData.Add("max", 100);
                optionsData.Add("default", 5);

                var list = new CustomdataInfo() { required = "1", options = optionsData };
                Uri postUrl = new Uri(string.Format("http://api.trumpia.com/rest/v1/{0}/customdata/{1}", username, customdataId));
                var response = client.PostAsJsonAsync(postUrl, list).Result;
                if (response.IsSuccessStatusCode)
                {
                    var p = response.Content.ReadAsAsync<Result>().Result;
                    string json = JsonConvert.SerializeObject(p);
                    Console.WriteLine(json);
                }
            }
        }
    }
}

DELETE Custom Data Field

Permanently remove a custom data field.

Resource Information

Response Formats JSON
Allowed Methods DELETE
URL http://api.trumpia.com/rest/v1/{user_name}/customdata/{customdata_id}
{user_name} Your account username (this can be found in the Account Settings page after logging in.)
{customdata_id} Delete the information for this custom data field ID.

Header Parameters

* required parameters
Parameter Description
Content-Type * application/json
X-Apikey * Your API key (This can be found in the API Settings page after logging in.)

Example value: 123456789abc1011

Code sample for DELETE Custom Data Field


"Request Example:
DELETE http://api.trumpia.com/rest/v1/{user_name}/customdata/{customdata_id}"

"Response Example:"
 {
  "request_id" : "1234561234567asdf123"
}



<?
	// DELETE Custom Data Field - Delete a custom data field.
	include "request_rest.php";

	$request_url = "http://api.trumpia.com/rest/v1/{user_name}/customdata";
	$customdata_id = "987987987980";
	$request_url =	$request_url . "/" . $customdata_id;

	$request_rest = new RestRequest();

	$request_rest->setRequestURL($request_url);
	$request_rest->setAPIKey("{api_key}");
	$request_rest->setMethod("DELETE");
	$result = $request_rest->execute();

	$response_status = $result[0];
	$json_response_data = $result[1];

	if ($response_status == "200") {	//success
		echo $json_response_data;
	} else {
		echo $response_status ." - connection failure";
	}
?>


// DELETE Custom Data Field - Delete a custom data field.
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="org.json.simple.JSONArray" %>
<%@ page import="org.json.simple.JSONObject" %>
<%@ page import="java.io.BufferedReader" %>
<%@ page import="java.io.IOException" %>
<%@ page import="java.io.InputStreamReader" %>
<%@ page import="java.io.OutputStream" %>
<%@ page import="java.io.OutputStreamWriter" %>
<%@ page import="java.io.Writer" %>
<%@ page import="java.net.HttpURLConnection" %>
<%@ page import="java.net.URL" %>
<html>
<title>CustomdataDelete Sample Code</title>
<body>

<%
	String username = "username";
	String customdataId = "987987987980";
	String urlStr = "http://api.trumpia.com/rest/v1/" + username + "/customdata/" + customdataId;
	URL url = new URL(urlStr);
	HttpURLConnection conn = (HttpURLConnection) url.openConnection();
	conn.setRequestMethod("DELETE");
	conn.setDoOutput(true);
	conn.setAllowUserInteraction(false);
	conn.setRequestProperty("Content-type", "application/json");
	conn.setRequestProperty("X-Apikey", "12345aaaaa67890aaaaa");
	if (conn.getResponseCode() != 200) {
%>
	Error : <%=conn.getResponseMessage()%>
<%
	}else{
	// Buffer the result into a string
	BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
	StringBuilder sb = new StringBuilder();
	String line;
	while ((line = rd.readLine()) != null) {
		sb.append(line);
	}
	rd.close();
	conn.disconnect();
%>
	Response : <%=sb.toString()%>
<%
	}
%>
</body>
</html>


// DELETE Custom Data Field - Delete a custom data field.
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;

namespace samplecode
{
    class Result
    {

        public string request_id { get; set; }
    }
    class CustomdataDelete
    {
        static void Main()
        {
            RunAsync().Wait();
        }

        static async Task RunAsync()
        {
            using (var client = new HttpClient())
            {
                var apikey = "12345aaaaa67890aaaaa";

                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Add("X-Apikey", string.Format("{0}", apikey));

                var username = "username";
                var customdataId = "987987987980";

                //DELETE
                Uri deleteUrl = new Uri(string.Format("http://api.trumpia.com/rest/v1/{0}/customdata/{1}", username, customdataId));
                var response = client.DeleteAsync(deleteUrl).Result;
                if (response.IsSuccessStatusCode)
                {
                    var p = response.Content.ReadAsAsync<Result>().Result;
                    string json = JsonConvert.SerializeObject(p);
                    Console.WriteLine(json);
                }
            }
        }
    }
}