API Guide / Getting Started / Sample Code
Sample Code

The below code C# is for API call request to update the customer status, such as status, owner, industry type and last activity date.

try

{

// Target URL

string url = "http://Witly.co/api/v2/account?id=112983be-fcc7-4cdd-b6f8-35b96cbe6780&token=5a812436e5f94125b18ee73b4680bb16";


// Sample Json string

string json = @"{

‘Status’: 'Prospect',

'owner' : 'John Doe',

'Industry Type’: 'Internet/Service',

'Last Activity Date’: '" + DateTime.Now.ToString("o") + "'" +

"}";


// Request (Send Json string as byte array)

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);

request.Method = "PUT";

request.ContentType = "application/json"; //"text/xml";

using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))

{

writer.Write(json);

}

// Response

HttpWebResponse response = (HttpWebResponse)request.GetResponse();

using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))

{

string result = reader.ReadToEnd();

Console.WriteLine(result);

}

}

catch (WebException e)

{

using (WebResponse response = e.Response)

{

if (response != null)

{

HttpWebResponse httpResponse = (HttpWebResponse)response;

Console.WriteLine("Error code: {0}", httpResponse.StatusCode);

using (Stream data = response.GetResponseStream())

using (StreamReader reader = new StreamReader(data))

{

string text = reader.ReadToEnd();

Console.WriteLine(text);

}

}

else

{

Console.WriteLine("Unknown  error!");

}

}

}


Last modified on Jan 23, 2018