For non required fields, you can either omit from the JSON string or set it to a default value
(e.g. String = "", Integer/Double = 0, Boolean = false, DateTime = 1900-01-01T00:00:00.000Z)
{"association": {"association_no": 0, "attribute_assign_no": 0, "auth_method": "", "credit_no": 0, "customer_exchange_no": 0, "customer_no": 0, "error_log_no": 0, "notification_type": "", "referrer": "", "searchfield": "", "subscription_no": 0, "activity_no": 0, "customer_credit_no": 0, "from_date": "1/1/1900 12:00 AM", "master_type": "", "timezone_offset": 0, "api_username": "", "component_no": 0, "error_received": "", "master_no": 0, "message_format": "", "search_for": "", "sessionid": "", "template_notification_no": 0, "to_date": "1/1/1900 12:00 AM", "api_password": "", "attribute_value": "", "category_no": 0, "ipaddress": "", "message_type": "", "stacktrace": "", "sub_no": 0, "total_results": 0, "api_key": "", "browseragent": "", "created_on": "1/1/1900 12:00 AM", "credits": 0, "error_page": "", "order_no": 0, "sort_by": "", "units": 0, "attribute_no": 0, "auth_type": "", "created_start": "1/1/1900 12:00 AM", "credit_cost": 0, "dollars": 0, "page_name": "", "return_objects": false, "template_notification": "", "transaction_no": 0, "user_no": 0, "attribute_name": "", "created_end": "1/1/1900 12:00 AM", "exchange_date": "1/1/1900 12:00 AM", "units_initial": 0, "username": "", "component_name": "", "field_type": "", "password": "", "reference_type": "", "resolved": false, "sortby": "", "units_remaining": 0, "category_name": "", "company_no": 0, "component_title": "", "dollars_initial": 0, "field_values": "", "notes": "", "reference_no": 0, "component_date": "1/1/1900 12:00 AM", "dollars_remaining": 0, "field_help": "", "ip_address": "", "system_name": "", "totalPurchases": 0, "activity_action": "", "system_company_no": 0, "totalRedemptions": 0, "expiration_date": "1/1/1900 12:00 AM", "query_string": "", "totalUnitsAvailable": 0, "status": "", "first_name": "", "last_name": "" }, "auth": {"api_username": "", "api_password": "", "api_key": "", "company_no": 0, "username": "", "password": "", "timezone_offset": 0, "auth_type": "", "system_name": "", "system_company_no": 0 } }
{"association": {"association_no": 0, "attribute_assign_no": 0, "auth_method": "", "credit_no": 0, "customer_exchange_no": 0, "customer_no": 0, "error_log_no": 0, "notification_type": "", "referrer": "", "searchfield": "", "subscription_no": 0, "activity_no": 0, "customer_credit_no": 0, "from_date": "1/1/1900 12:00 AM", "master_type": "", "timezone_offset": 0, "api_username": "", "component_no": 0, "error_received": "", "master_no": 0, "message_format": "", "search_for": "", "sessionid": "", "template_notification_no": 0, "to_date": "1/1/1900 12:00 AM", "api_password": "", "attribute_value": "", "category_no": 0, "ipaddress": "", "message_type": "", "stacktrace": "", "sub_no": 0, "total_results": 0, "api_key": "", "browseragent": "", "created_on": "1/1/1900 12:00 AM", "credits": 0, "error_page": "", "order_no": 0, "sort_by": "", "units": 0, "attribute_no": 0, "auth_type": "", "created_start": "1/1/1900 12:00 AM", "credit_cost": 0, "dollars": 0, "page_name": "", "return_objects": false, "template_notification": "", "transaction_no": 0, "user_no": 0, "attribute_name": "", "created_end": "1/1/1900 12:00 AM", "exchange_date": "1/1/1900 12:00 AM", "units_initial": 0, "username": "", "component_name": "", "field_type": "", "password": "", "reference_type": "", "resolved": false, "sortby": "", "units_remaining": 0, "category_name": "", "company_no": 0, "component_title": "", "dollars_initial": 0, "field_values": "", "notes": "", "reference_no": 0, "component_date": "1/1/1900 12:00 AM", "dollars_remaining": 0, "field_help": "", "ip_address": "", "system_name": "", "totalPurchases": 0, "activity_action": "", "system_company_no": 0, "totalRedemptions": 0, "expiration_date": "1/1/1900 12:00 AM", "query_string": "", "totalUnitsAvailable": 0, "status": "", "first_name": "", "last_name": "" }, "auth": {"api_username": "", "api_password": "", "api_key": "", "company_no": 0, "username": "", "password": "" } }
This sample code is to generate a function leveraging existing core functions you've already built.
func getAPIKit() -> (url: String, dict: Dictionary<String, AnyObject>) {
var association_no = 0
var attribute_assign_no = 0
var auth_method = ""
var credit_no = 0
var customer_exchange_no = 0
var customer_no = 0
var error_log_no = 0
var notification_type = ""
var referrer = ""
var searchfield = ""
var subscription_no = 0
var activity_no = 0
var customer_credit_no = 0
var from_date = "1/1/1900 12:00 AM"
var master_type = ""
var timezone_offset = 0
var api_username = ""
var component_no = 0
var error_received = ""
var master_no = 0
var message_format = ""
var search_for = ""
var sessionid = ""
var template_notification_no = 0
var to_date = "1/1/1900 12:00 AM"
var api_password = ""
var attribute_value = ""
var category_no = 0
var ipaddress = ""
var message_type = ""
var stacktrace = ""
var sub_no = 0
var total_results = 0
var api_key = ""
var browseragent = ""
var created_on = "1/1/1900 12:00 AM"
var credits = 0
var error_page = ""
var order_no = 0
var sort_by = ""
var units = 0
var attribute_no = 0
var auth_type = ""
var created_start = "1/1/1900 12:00 AM"
var credit_cost = 0
var dollars = 0
var page_name = ""
var return_objects = false
var template_notification = ""
var transaction_no = 0
var user_no = 0
var attribute_name = ""
var created_end = "1/1/1900 12:00 AM"
var exchange_date = "1/1/1900 12:00 AM"
var units_initial = 0
var username = ""
var component_name = ""
var field_type = ""
var password = ""
var reference_type = ""
var resolved = false
var sortby = ""
var units_remaining = 0
var category_name = ""
var company_no = 0
var component_title = ""
var dollars_initial = 0
var field_values = ""
var notes = ""
var reference_no = 0
var component_date = "1/1/1900 12:00 AM"
var dollars_remaining = 0
var field_help = ""
var ip_address = ""
var system_name = ""
var totalPurchases = 0
var activity_action = ""
var system_company_no = 0
var totalRedemptions = 0
var expiration_date = "1/1/1900 12:00 AM"
var query_string = ""
var totalUnitsAvailable = 0
var status = ""
var first_name = ""
var last_name = ""
let url = "https://api.peoplevine.com/general.asmx/deleteAssociation"
let key = "association"
let associationDict: Dictionary<String, AnyObject> = ["association_no": association_no, "attribute_assign_no": attribute_assign_no, "auth_method": auth_method, "credit_no": credit_no, "customer_exchange_no": customer_exchange_no, "customer_no": customer_no, "error_log_no": error_log_no, "notification_type": notification_type, "referrer": referrer, "searchfield": searchfield, "subscription_no": subscription_no, "activity_no": activity_no, "customer_credit_no": customer_credit_no, "from_date": from_date, "master_type": master_type, "timezone_offset": timezone_offset, "api_username": api_username, "component_no": component_no, "error_received": error_received, "master_no": master_no, "message_format": message_format, "search_for": search_for, "sessionid": sessionid, "template_notification_no": template_notification_no, "to_date": to_date, "api_password": api_password, "attribute_value": attribute_value, "category_no": category_no, "ipaddress": ipaddress, "message_type": message_type, "stacktrace": stacktrace, "sub_no": sub_no, "total_results": total_results, "api_key": api_key, "browseragent": browseragent, "created_on": created_on, "credits": credits, "error_page": error_page, "order_no": order_no, "sort_by": sort_by, "units": units, "attribute_no": attribute_no, "auth_type": auth_type, "created_start": created_start, "credit_cost": credit_cost, "dollars": dollars, "page_name": page_name, "return_objects": return_objects, "template_notification": template_notification, "transaction_no": transaction_no, "user_no": user_no, "attribute_name": attribute_name, "created_end": created_end, "exchange_date": exchange_date, "units_initial": units_initial, "username": username, "component_name": component_name, "field_type": field_type, "password": password, "reference_type": reference_type, "resolved": resolved, "sortby": sortby, "units_remaining": units_remaining, "category_name": category_name, "company_no": company_no, "component_title": component_title, "dollars_initial": dollars_initial, "field_values": field_values, "notes": notes, "reference_no": reference_no, "component_date": component_date, "dollars_remaining": dollars_remaining, "field_help": field_help, "ip_address": ip_address, "system_name": system_name, "totalPurchases": totalPurchases, "activity_action": activity_action, "system_company_no": system_company_no, "totalRedemptions": totalRedemptions, "expiration_date": expiration_date, "query_string": query_string, "totalUnitsAvailable": totalUnitsAvailable, "status": status, "first_name": first_name, "last_name": last_name ]
let finalDict = User.getAuthDict(dictToAdd: associationDict, dictKey: key)
return (url, finalDict)
}
To get started we reccomend that you download the Alamofire project to simplify integration: https://github.com/Alamofire/Alamofire, in addition to SwiftyJSON: https://github.com/SwiftyJSON/SwiftyJSON
import Foundation
struct ASSOCIATION {
static var association_no = <double>
static var attribute_assign_no = <double>
static var auth_method = <string>
static var credit_no = <double>
static var customer_exchange_no = <double>
static var customer_no = <double>
static var error_log_no = <double>
static var notification_type = <string>
static var referrer = <string>
static var searchfield = <string>
static var subscription_no = <double>
static var activity_no = <double>
static var customer_credit_no = <double>
static var from_date = <dateTime>
static var master_type = <string>
static var timezone_offset = <double>
static var api_username = <string>
static var component_no = <double>
static var error_received = <string>
static var master_no = <double>
static var message_format = <string>
static var search_for = <string>
static var sessionid = <string>
static var template_notification_no = <double>
static var to_date = <dateTime>
static var api_password = <string>
static var attribute_value = <string>
static var category_no = <double>
static var ipaddress = <string>
static var message_type = <string>
static var stacktrace = <string>
static var sub_no = <double>
static var total_results = <double>
static var api_key = <string>
static var browseragent = <string>
static var created_on = <dateTime>
static var credits = <double>
static var error_page = <string>
static var order_no = <double>
static var sort_by = <string>
static var units = <double>
static var attribute_no = <double>
static var auth_type = <string>
static var created_start = <dateTime>
static var credit_cost = <double>
static var dollars = <double>
static var page_name = <string>
static var return_objects = <boolean>
static var template_notification = <string>
static var transaction_no = <double>
static var user_no = <double>
static var attribute_name = <string>
static var created_end = <dateTime>
static var exchange_date = <dateTime>
static var units_initial = <double>
static var username = <string>
static var component_name = <string>
static var field_type = <string>
static var password = <string>
static var reference_type = <string>
static var resolved = <boolean>
static var sortby = <string>
static var units_remaining = <double>
static var category_name = <string>
static var company_no = <double>
static var component_title = <string>
static var dollars_initial = <double>
static var field_values = <string>
static var notes = <string>
static var reference_no = <double>
static var component_date = <dateTime>
static var dollars_remaining = <double>
static var field_help = <string>
static var ip_address = <string>
static var system_name = <string>
static var totalPurchases = <double>
static var activity_action = <string>
static var system_company_no = <double>
static var totalRedemptions = <double>
static var expiration_date = <dateTime>
static var query_string = <string>
static var totalUnitsAvailable = <double>
static var status = <string>
static var first_name = <string>
static var last_name = <string>}
struct AUTH {
static var api_username = <string>
static var api_password = <string>
static var api_key = <string>
static var company_no = <double>
static var username = <string>
static var password = <string>
static var timezone_offset = <double>
static var auth_type = <string>
static var system_name = <string>
static var system_company_no = <double>}
func deleteAssociationRequest() {
var deleteAssociationObjects = [AnyObject]()
let postsEndpoint: String = "https://api.peoplevine.com/general.asmx/deleteAssociation"
let authAndFieldsDict = ["association": ["association_no": ASSOCIATION.association_no, "attribute_assign_no": ASSOCIATION.attribute_assign_no, "auth_method": ASSOCIATION.auth_method, "credit_no": ASSOCIATION.credit_no, "customer_exchange_no": ASSOCIATION.customer_exchange_no, "customer_no": ASSOCIATION.customer_no, "error_log_no": ASSOCIATION.error_log_no, "notification_type": ASSOCIATION.notification_type, "referrer": ASSOCIATION.referrer, "searchfield": ASSOCIATION.searchfield, "subscription_no": ASSOCIATION.subscription_no, "activity_no": ASSOCIATION.activity_no, "customer_credit_no": ASSOCIATION.customer_credit_no, "from_date": ASSOCIATION.from_date, "master_type": ASSOCIATION.master_type, "timezone_offset": ASSOCIATION.timezone_offset, "api_username": ASSOCIATION.api_username, "component_no": ASSOCIATION.component_no, "error_received": ASSOCIATION.error_received, "master_no": ASSOCIATION.master_no, "message_format": ASSOCIATION.message_format, "search_for": ASSOCIATION.search_for, "sessionid": ASSOCIATION.sessionid, "template_notification_no": ASSOCIATION.template_notification_no, "to_date": ASSOCIATION.to_date, "api_password": ASSOCIATION.api_password, "attribute_value": ASSOCIATION.attribute_value, "category_no": ASSOCIATION.category_no, "ipaddress": ASSOCIATION.ipaddress, "message_type": ASSOCIATION.message_type, "stacktrace": ASSOCIATION.stacktrace, "sub_no": ASSOCIATION.sub_no, "total_results": ASSOCIATION.total_results, "api_key": ASSOCIATION.api_key, "browseragent": ASSOCIATION.browseragent, "created_on": ASSOCIATION.created_on, "credits": ASSOCIATION.credits, "error_page": ASSOCIATION.error_page, "order_no": ASSOCIATION.order_no, "sort_by": ASSOCIATION.sort_by, "units": ASSOCIATION.units, "attribute_no": ASSOCIATION.attribute_no, "auth_type": ASSOCIATION.auth_type, "created_start": ASSOCIATION.created_start, "credit_cost": ASSOCIATION.credit_cost, "dollars": ASSOCIATION.dollars, "page_name": ASSOCIATION.page_name, "return_objects": ASSOCIATION.return_objects, "template_notification": ASSOCIATION.template_notification, "transaction_no": ASSOCIATION.transaction_no, "user_no": ASSOCIATION.user_no, "attribute_name": ASSOCIATION.attribute_name, "created_end": ASSOCIATION.created_end, "exchange_date": ASSOCIATION.exchange_date, "units_initial": ASSOCIATION.units_initial, "username": ASSOCIATION.username, "component_name": ASSOCIATION.component_name, "field_type": ASSOCIATION.field_type, "password": ASSOCIATION.password, "reference_type": ASSOCIATION.reference_type, "resolved": ASSOCIATION.resolved, "sortby": ASSOCIATION.sortby, "units_remaining": ASSOCIATION.units_remaining, "category_name": ASSOCIATION.category_name, "company_no": ASSOCIATION.company_no, "component_title": ASSOCIATION.component_title, "dollars_initial": ASSOCIATION.dollars_initial, "field_values": ASSOCIATION.field_values, "notes": ASSOCIATION.notes, "reference_no": ASSOCIATION.reference_no, "component_date": ASSOCIATION.component_date, "dollars_remaining": ASSOCIATION.dollars_remaining, "field_help": ASSOCIATION.field_help, "ip_address": ASSOCIATION.ip_address, "system_name": ASSOCIATION.system_name, "totalPurchases": ASSOCIATION.totalPurchases, "activity_action": ASSOCIATION.activity_action, "system_company_no": ASSOCIATION.system_company_no, "totalRedemptions": ASSOCIATION.totalRedemptions, "expiration_date": ASSOCIATION.expiration_date, "query_string": ASSOCIATION.query_string, "totalUnitsAvailable": ASSOCIATION.totalUnitsAvailable, "status": ASSOCIATION.status, "first_name": ASSOCIATION.first_name, "last_name": ASSOCIATION.last_name ], "auth": ["api_username": AUTH.api_username, "api_password": AUTH.api_password, "api_key": AUTH.api_key, "company_no": AUTH.company_no, "username": AUTH.username, "password": AUTH.password, "timezone_offset": AUTH.timezone_offset, "auth_type": AUTH.auth_type, "system_name": AUTH.system_name, "system_company_no": AUTH.system_company_no ] ]
Alamofire.request(.POST, postsEndpoint, parameters: authAndFieldsDict, encoding: .JSON).responseJSON { (request, response, data, error) in
if let anError = error {
println("error calling POST on /posts")
println(error)
} else if let jsonData: AnyObject = data {
if let dataString = (jsonData.valueForKey("d") as! String).dataUsingEncoding(NSUTF8StringEncoding) {
let json = JSON(data: dataString) //use this object to parse data
//SAMPLE PARSING
let varData = json["returnObject"][0]["object"].stringValue
// ----------
// BELOW REPRESENTS AN EXAMPLE USING PURE SWIFT JSONSERIALIZATION INSTEAD OF SWIFTYJSON --------//
// if let deleteAssociationDict = NSJSONSerialization.JSONObjectWithData(encoString, options: .MutableContainers, error: nil) as? NSDictionary {
// if let returnObjectArray = deleteAssociationDict["returnObject"] as? NSArray {
//
// for deleteAssociationObject in returnObjectArray {
// deleteAssociationObjects.append(deleteAssociationObject)
// if let item = deleteAssociationObject["object_name"] as? NSDictionary {
// let varItem = item["field_name"] as! String
// }
// }
//
// println("\n\(deleteAssociationObjects.count) Total")
// }
// }
}
}
}
}
<!DOCTYPE html>
<html>
<head>
<title>API Call - deleteAssociation</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(function() {
var dataValue = {
"association": {
"association_no": 0,
"attribute_assign_no": 0,
"auth_method": "",
"credit_no": 0,
"customer_exchange_no": 0,
"customer_no": 0,
"error_log_no": 0,
"notification_type": "",
"referrer": "",
"searchfield": "",
"subscription_no": 0,
"activity_no": 0,
"customer_credit_no": 0,
"from_date": "1/1/1900 12:00 AM",
"master_type": "",
"timezone_offset": 0,
"api_username": "",
"component_no": 0,
"error_received": "",
"master_no": 0,
"message_format": "",
"search_for": "",
"sessionid": "",
"template_notification_no": 0,
"to_date": "1/1/1900 12:00 AM",
"api_password": "",
"attribute_value": "",
"category_no": 0,
"ipaddress": "",
"message_type": "",
"stacktrace": "",
"sub_no": 0,
"total_results": 0,
"api_key": "",
"browseragent": "",
"created_on": "1/1/1900 12:00 AM",
"credits": 0,
"error_page": "",
"order_no": 0,
"sort_by": "",
"units": 0,
"attribute_no": 0,
"auth_type": "",
"created_start": "1/1/1900 12:00 AM",
"credit_cost": 0,
"dollars": 0,
"page_name": "",
"return_objects": false,
"template_notification": "",
"transaction_no": 0,
"user_no": 0,
"attribute_name": "",
"created_end": "1/1/1900 12:00 AM",
"exchange_date": "1/1/1900 12:00 AM",
"units_initial": 0,
"username": "",
"component_name": "",
"field_type": "",
"password": "",
"reference_type": "",
"resolved": false,
"sortby": "",
"units_remaining": 0,
"category_name": "",
"company_no": 0,
"component_title": "",
"dollars_initial": 0,
"field_values": "",
"notes": "",
"reference_no": 0,
"component_date": "1/1/1900 12:00 AM",
"dollars_remaining": 0,
"field_help": "",
"ip_address": "",
"system_name": "",
"totalPurchases": 0,
"activity_action": "",
"system_company_no": 0,
"totalRedemptions": 0,
"expiration_date": "1/1/1900 12:00 AM",
"query_string": "",
"totalUnitsAvailable": 0,
"status": "",
"first_name": "",
"last_name": "",
},
"auth": {
"api_username": "",
"api_password": "",
"api_key": "",
"company_no": 0,
"username": "",
"password": "",
"timezone_offset": 0,
"auth_type": "",
"system_name": "",
"system_company_no": 0,
},
};
$.ajax({
url: 'https://api.peoplevine.com/general.asmx/deleteAssociation',
type: 'POST',
data: JSON.stringify(dataValue),
contentType: 'application/json; charset=utf-8',
dataType: 'json',
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("ERROR");
},
success: function (result) {
var obj = JSON.parse(result.d).returnObject;
$.each(obj, function(i) {
$("#divID").html(obj[i].field_name); //do something with the data
})
}
})
});
</script>
</body>
</html>
System.Net.HttpWebRequest req = System.Net.HttpWebRequest.Create("https://api.peoplevine.com/general.asmx/deleteAssociation");
req.Method = "POST";
req.ContentType = "application/json; charset=utf-8";
string dataValue = "{association: {association_no: <double>, attribute_assign_no: <double>, auth_method: <string>, credit_no: <double>, customer_exchange_no: <double>, customer_no: <double>, error_log_no: <double>, notification_type: <string>, referrer: <string>, searchfield: <string>, subscription_no: <double>, activity_no: <double>, customer_credit_no: <double>, from_date: <dateTime>, master_type: <string>, timezone_offset: <double>, api_username: <string>, component_no: <double>, error_received: <string>, master_no: <double>, message_format: <string>, search_for: <string>, sessionid: <string>, template_notification_no: <double>, to_date: <dateTime>, api_password: <string>, attribute_value: <string>, category_no: <double>, ipaddress: <string>, message_type: <string>, stacktrace: <string>, sub_no: <double>, total_results: <double>, api_key: <string>, browseragent: <string>, created_on: <dateTime>, credits: <double>, error_page: <string>, order_no: <double>, sort_by: <string>, units: <double>, attribute_no: <double>, auth_type: <string>, created_start: <dateTime>, credit_cost: <double>, dollars: <double>, page_name: <string>, return_objects: <boolean>, template_notification: <string>, transaction_no: <double>, user_no: <double>, attribute_name: <string>, created_end: <dateTime>, exchange_date: <dateTime>, units_initial: <double>, username: <string>, component_name: <string>, field_type: <string>, password: <string>, reference_type: <string>, resolved: <boolean>, sortby: <string>, units_remaining: <double>, category_name: <string>, company_no: <double>, component_title: <string>, dollars_initial: <double>, field_values: <string>, notes: <string>, reference_no: <double>, component_date: <dateTime>, dollars_remaining: <double>, field_help: <string>, ip_address: <string>, system_name: <string>, totalPurchases: <double>, activity_action: <string>, system_company_no: <double>, totalRedemptions: <double>, expiration_date: <dateTime>, query_string: <string>, totalUnitsAvailable: <double>, status: <string>, first_name: <string>, last_name: <string> },auth: {api_username: <string>, api_password: <string>, api_key: <string>, company_no: <double>, username: <string>, password: <string>, timezone_offset: <double>, auth_type: <string>, system_name: <string>, system_company_no: <double> }}";
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] bytes = encoding.GetBytes(dataValue);
req.ContentLength = bytes.Length;
System.IO.Stream strm = req.GetRequestStream();
strm.Write(bytes, 0, bytes.Length);
strm.Close();
System.Net.HttpWebResponse rsp = req.GetResponse();
System.IO.Stream data = rsp.GetResponseStream();
System.IO.StreamReader rdr = new System.IO.StreamReader(data);
string response = rdr.ReadToEnd();
Dim req As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("https://api.peoplevine.com/general.asmx/deleteAssociation")
req.Method = "POST"
req.ContentType = "application/json; charset=utf-8"
Dim dataValue As String = "{association: {association_no: <double>, attribute_assign_no: <double>, auth_method: <string>, credit_no: <double>, customer_exchange_no: <double>, customer_no: <double>, error_log_no: <double>, notification_type: <string>, referrer: <string>, searchfield: <string>, subscription_no: <double>, activity_no: <double>, customer_credit_no: <double>, from_date: <dateTime>, master_type: <string>, timezone_offset: <double>, api_username: <string>, component_no: <double>, error_received: <string>, master_no: <double>, message_format: <string>, search_for: <string>, sessionid: <string>, template_notification_no: <double>, to_date: <dateTime>, api_password: <string>, attribute_value: <string>, category_no: <double>, ipaddress: <string>, message_type: <string>, stacktrace: <string>, sub_no: <double>, total_results: <double>, api_key: <string>, browseragent: <string>, created_on: <dateTime>, credits: <double>, error_page: <string>, order_no: <double>, sort_by: <string>, units: <double>, attribute_no: <double>, auth_type: <string>, created_start: <dateTime>, credit_cost: <double>, dollars: <double>, page_name: <string>, return_objects: <boolean>, template_notification: <string>, transaction_no: <double>, user_no: <double>, attribute_name: <string>, created_end: <dateTime>, exchange_date: <dateTime>, units_initial: <double>, username: <string>, component_name: <string>, field_type: <string>, password: <string>, reference_type: <string>, resolved: <boolean>, sortby: <string>, units_remaining: <double>, category_name: <string>, company_no: <double>, component_title: <string>, dollars_initial: <double>, field_values: <string>, notes: <string>, reference_no: <double>, component_date: <dateTime>, dollars_remaining: <double>, field_help: <string>, ip_address: <string>, system_name: <string>, totalPurchases: <double>, activity_action: <string>, system_company_no: <double>, totalRedemptions: <double>, expiration_date: <dateTime>, query_string: <string>, totalUnitsAvailable: <double>, status: <string>, first_name: <string>, last_name: <string> },auth: {api_username: <string>, api_password: <string>, api_key: <string>, company_no: <double>, username: <string>, password: <string>, timezone_offset: <double>, auth_type: <string>, system_name: <string>, system_company_no: <double> }}"
Dim encoding As New ASCIIEncoding()
Dim bytes As Byte() = encoding.GetBytes(dataValue)
req.ContentLength = bytes.Length
Dim strm As System.IO.Stream = req.GetRequestStream()
strm.Write(bytes, 0, bytes.Length)
strm.Close()
Dim rsp As System.Net.HttpWebResponse = req.GetResponse()
Dim data As System.IO.Stream = rsp.GetResponseStream()
Dim rdr As New System.IO.StreamReader(data)
Dim response As String = rdr.ReadToEnd()
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
public class JavaSample {
public static void main(String[] args) {
HttpClient httpclient = HttpClients.createDefault();
try
{
URIBuilder builder = new URIBuilder("https://peoplevine.azure-api.net/customer/customer/registerCustomer");
// Specify your subscription key
builder.setParameter("subscription-key", "");
URI uri = builder.build();
HttpPost request = new HttpPost(uri);
StringEntity reqEntity = new StringEntity("", ContentType.create("application/json"));
request.setEntity(reqEntity);
HttpResponse response = httpclient.execute(request);
HttpEntity entity = response.getEntity();
if (entity != null) {
System.out.println(EntityUtils.toString(entity));
}
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
}
<?php
// This sample uses the HTTP_Request2 package. (for more information: http://pear.php.net/package/HTTP_Request2)
require_once 'HTTP/Request2.php';
$headers = array(
'Content-Type' => 'application/json',
);
$query_params = array(
// Specify your subscription key
'subscription-key' => '',
);
$request = new Http_Request2('https://peoplevine.azure-api.net/customer/customer/registerCustomer');
$request->setMethod(HTTP_Request2::METHOD_POST);
// Basic Authorization Sample
// $request-setAuth('{username}', '{password}');
$request->setHeader($headers);
$url = $request->getUrl();
$url->setQueryVariables($query_params);
$request->setBody("");
try
{
$response = $request->send();
echo $response->getBody();
}
catch (HttpException $ex)
{
echo $ex;
}
?>
#import <Foundation/Foundation.h>
NSDictionary *associationDic = [NSDictionary dictionaryWithObjectsAndKeys:
<double>, @"association_no",
<double>, @"attribute_assign_no",
<string>, @"auth_method",
<double>, @"credit_no",
<double>, @"customer_exchange_no",
<double>, @"customer_no",
<double>, @"error_log_no",
<string>, @"notification_type",
<string>, @"referrer",
<string>, @"searchfield",
<double>, @"subscription_no",
<double>, @"activity_no",
<double>, @"customer_credit_no",
<dateTime>, @"from_date",
<string>, @"master_type",
<double>, @"timezone_offset",
<string>, @"api_username",
<double>, @"component_no",
<string>, @"error_received",
<double>, @"master_no",
<string>, @"message_format",
<string>, @"search_for",
<string>, @"sessionid",
<double>, @"template_notification_no",
<dateTime>, @"to_date",
<string>, @"api_password",
<string>, @"attribute_value",
<double>, @"category_no",
<string>, @"ipaddress",
<string>, @"message_type",
<string>, @"stacktrace",
<double>, @"sub_no",
<double>, @"total_results",
<string>, @"api_key",
<string>, @"browseragent",
<dateTime>, @"created_on",
<double>, @"credits",
<string>, @"error_page",
<double>, @"order_no",
<string>, @"sort_by",
<double>, @"units",
<double>, @"attribute_no",
<string>, @"auth_type",
<dateTime>, @"created_start",
<double>, @"credit_cost",
<double>, @"dollars",
<string>, @"page_name",
<boolean>, @"return_objects",
<string>, @"template_notification",
<double>, @"transaction_no",
<double>, @"user_no",
<string>, @"attribute_name",
<dateTime>, @"created_end",
<dateTime>, @"exchange_date",
<double>, @"units_initial",
<string>, @"username",
<string>, @"component_name",
<string>, @"field_type",
<string>, @"password",
<string>, @"reference_type",
<boolean>, @"resolved",
<string>, @"sortby",
<double>, @"units_remaining",
<string>, @"category_name",
<double>, @"company_no",
<string>, @"component_title",
<double>, @"dollars_initial",
<string>, @"field_values",
<string>, @"notes",
<double>, @"reference_no",
<dateTime>, @"component_date",
<double>, @"dollars_remaining",
<string>, @"field_help",
<string>, @"ip_address",
<string>, @"system_name",
<double>, @"totalPurchases",
<string>, @"activity_action",
<double>, @"system_company_no",
<double>, @"totalRedemptions",
<dateTime>, @"expiration_date",
<string>, @"query_string",
<double>, @"totalUnitsAvailable",
<string>, @"status",
<string>, @"first_name",
<string>, @"last_name", nil];
NSDictionary *authDic = [NSDictionary dictionaryWithObjectsAndKeys:
<string>, @"api_username",
<string>, @"api_password",
<string>, @"api_key",
<double>, @"company_no",
<string>, @"username",
<string>, @"password",
<double>, @"timezone_offset",
<string>, @"auth_type",
<string>, @"system_name",
<double>, @"system_company_no", nil];
NSDictionary *finalDic = [NSDictionary dictionaryWithObjectsAndKeys:
associationDic, @"association",authDic, @"auth", nil];
NSMutableDictionary* jsonString = nil;
jsonString = [NSJSONSerialization JSONObjectWithData: findalDic options:NSJSONReadingMutableContainers];
NSMutableData *bodyData = [NSMutableData dataWithData:[jsonString dataUsingEncoding:NSUTF8StringEncoding]];
NSString *urlString = @"https://api.peoplevine.com/general.asmx/deleteAssociation";
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:urlString]];
[request setTimeOutSeconds:250];
[request setRequestMethod:@"POST"];
[request addRequestHeader:@"Content-Type" value:@"application/json"];
[request addRequestHeader:[NSString stringWithFormat:@"%d",bodyData.length] value:@"Content-length"];
[request setPostBody:bodyData];
[request startSynchronous];
NSDictionary *responseDic = (NSDictionary*)[request.responseString JSONValue];
if (responseDic || [responseDic objectForKey:@"d"])
{
NSMutableDictionary *dicSave=[responseDic objectForKey:@"d"];
// -------------------------------------------------------------------
// convert into the data and NSUTF8StringEncoding
// -------------------------------------------------------------------
NSString *strDic=[dicSave copy];
NSMutableDictionary *dirJson;
if (strDic)
{
NSData* dataFile=[strDic dataUsingEncoding:NSUTF8StringEncoding];
NSString* newStr = [[NSString alloc] initWithData:dataFile
encoding:NSUTF8StringEncoding];
dirJson = [newStr JSONValue] ;
}
// -------------------------------------------------------------------
NSString *str=[[dirJson objectForKey:@"returnObject"]valueForKey:@"customer_no"];
}
else
{
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Error" message:@"An Error Occurred" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
}
require 'net/http'
uri = URI('https://peoplevine.azure-api.net/customer/customer/registerCustomer')
uri.query = URI.encode_www_form({
# Specify your subscription key
'subscription-key' => '',
})
request = Net::HTTP::Post.new(uri.request_uri)
# Basic Authorization Sample
# request.basic_auth 'username', 'password'
request['Content-type'] = 'application/json'
request.body = ""
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
http.request(request)
end
puts response.body
########### Python 2.7 #############
import httplib, urllib, base64
headers = {
# Basic Authorization Sample
# 'Authorization': 'Basic %s' % base64.encodestring('{username}:{password}'),
'Content-type': 'application/json',
}
params = urllib.urlencode({
# Specify your subscription key
'subscription-key': '',
})
try:
conn = httplib.HTTPSConnection('peoplevine.azure-api.net')
conn.request("POST", "/customer/customer/registerCustomer?%s" % params, "", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64
headers = {
# Basic Authorization Sample
# 'Authorization': 'Basic %s' % base64.encodestring('{username}:{password}'),
'Content-type': 'application/json',
}
params = urllib.parse.urlencode({
# Specify your subscription key
'subscription-key': '',
})
try:
conn = http.client.HTTPSConnection('peoplevine.azure-api.net')
conn.request("POST", "/customer/customer/registerCustomer?%s" % params, "", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
@ECHO OFF
REM for Basic Authorization use: --user {username}:{password}
REM Specify values for path parameters (shown as {...}), your subscription key and values for query parameters
curl -v -X POST "https://peoplevine.azure-api.net/customer/customer/registerCustomer?subscription-key="^
-H "Content-Type: application/json"