This link is showing how to create a record for Leads, but I want to create it for Contacts.
I will put my code here, but it's almost the same what I got from there. So, do you know what can be a problem and how to create a Contacts?
public void CreateZohoRecord(string moduleAPIName)
{
//API Name of the module to create records
//string moduleAPIName = "Leads";
//Get instance of RecordOperations Class
RecordOperations recordOperations = new RecordOperations();
//Get instance of BodyWrapper Class that will contain the request body
BodyWrapper bodyWrapper = new BodyWrapper();
//List of Record instances
List<Record> records = new List<Record>();
//Get instance of Record Class
Record record1 = new Record();
ParameterMap paramInstance = new ParameterMap();
/*
* Call addFieldValue method that takes two arguments
* 1 -> Call Field "." and choose the module from the displayed list and press "." and choose the field name from the displayed list.
* 2 -> Value
*/
record1.AddFieldValue(Leads.CITY, "Copenhagen");
record1.AddFieldValue(Leads.LAST_NAME, "Radzakova");
record1.AddFieldValue(Leads.FIRST_NAME, "Radzakov");
record1.AddFieldValue(Leads.COMPANY, "BNW");
record1.AddFieldValue(Leads.ID, 5005490902343243242);
/*
* Call addKeyValue method that takes two arguments
* 1 -> A string that is the Field's API Name
* 2 -> Value
*/
record1.AddKeyValue("Custom_field", "Value");
record1.AddKeyValue("External", "TestExternal12321345");
record1.AddKeyValue("Custom_field_2", "value");
record1.AddKeyValue("Date_Time_2", new DateTimeOffset(new DateTime(2020, 05, 15, 12, 0, 0, DateTimeKind.Local)));
record1.AddKeyValue("Date_1", new DateTime(2021, 1, 13).Date);
record1.AddKeyValue("Subject", "AutomatedSDK");
HeaderMap headerInstance = new HeaderMap();
headerInstance.Add(GetRecordsHeader.X_EXTERNAL, "Contacts.External");
APIResponse<ResponseHandler> response = operations.GetRecords(moduleAPIName, paramInstance, headerInstance);
if (response != null)
{
//Get the status code from response
Console.WriteLine("Status Code: " + response.StatusCode);
//Check if expected response is received
if (response.IsExpected)
{
//Get object from response
ActionHandler actionHandler = (ActionHandler)response.Object;
if (actionHandler is ActionWrapper)
{
//Get the received ActionWrapper instance
ActionWrapper actionWrapper = (ActionWrapper)actionHandler;
//Get the list of obtained ActionResponse instances
List<ActionResponse> actionResponses = actionWrapper.Data;
foreach (ActionResponse actionResponse in actionResponses)
{
//Check if the request is successful
if (actionResponse is SuccessResponse)
{
//Get the received SuccessResponse instance
SuccessResponse successResponse = (SuccessResponse)actionResponse;
//Get the Status
Console.WriteLine("Status: " + successResponse.Status.Value);
//Get the Code
Console.WriteLine("Code: " + successResponse.Code.Value);
Console.WriteLine("Details: ");
//Get the details map
foreach (KeyValuePair<string, object> entry in successResponse.Details)
{
//Get each value in the map
Console.WriteLine(entry.Key + ": " + JsonConvert.SerializeObject(entry.Value));
}
//Get the Message
Console.WriteLine("Message: " + successResponse.Message.Value);
}
//Check if the request returned an exception
else if (actionResponse is APIException)
{
//Get the received APIException instance
APIException exception = (APIException)actionResponse;
//Get the Status
Console.WriteLine("Status: " + exception.Status.Value);
//Get the Code
Console.WriteLine("Code: " + exception.Code.Value);
Console.WriteLine("Details: ");
//Get the details map
foreach (KeyValuePair<string, object> entry in exception.Details)
{
//Get each value in the map
Console.WriteLine(entry.Key + ": " + JsonConvert.SerializeObject(entry.Value));
}
//Get the Message
Console.WriteLine("Message: " + exception.Message.Value);
}
}
}
}
}
}