public static void Main() { try { AutotaskApiTests test = new AutotaskApiTests( ConfigurationManager.AppSettings["APIUsername"], ConfigurationManager.AppSettings["APIPassword"], ConfigurationManager.AppSettings["APITrackingID"]); // Search for a resource given a username long resourceId = test.FindResource("RESOURCE USER NAME"); long resourceId2 = test.FindResource("RESOURCE USER NAME"); // Create Ticket Note Impersonated as resource above AccountNote note = test.CreateAccountNoteAs(resourceId, resourceId2, DateTime.Now, DateTime.Now.AddDays(5)); // Search for a Contact given an email address Contact contact = test.FindContact("CONTACT EMAIL ADDRESS"); // Update Contact UDF contact = test.UpdateContactUdf(contact, "UDF NAME", "UDF VALUE"); // Update Contact Picklist UDF contact = test.UpdateContactUdfPicklist(contact, "UDF NAME", "UDF PICKLIST LABEL"); // Create NEW Contact with UDF Contact newContact = test.CreateContact(Convert.ToInt64(contact.AccountID), "FIRST NAME", "LAST NAME", "EMAIL", "UDF NAME", "UDF VALUE"); } catch (Exception ex) { throw new Exception("Error: " + ex.Message); } }
public void SaveAccountNote() { var accountNote = new AccountNote { AccountId = 0, ActionDate = DateTime.Now.ToShortDateString(), EntryDate = DateTime.Now.ToShortDateString(), Status = true, Subject = "A new note about this account", Note = "A Note Here." }; var newAccountNote = Api.AccountNoteRequest.Save(accountNote); }
public AccountNote Save(AccountNote accountNote) { var url = string.Format("AccountNote/Save?apikey={0}&companyid={1}", _apiKey, _companyId); var request = new RestRequest(url, Method.POST) { JsonSerializer = new JsonSerializer() }; request.RequestFormat = DataFormat.Json; request.AddBody(accountNote); var response = _client.Execute <AccountNote>(request); return(response.Data); }
/// <summary> /// Creates a ticket note by the provided resource id using Impersonation. /// </summary> /// <param name="assignResourceId">The resource id.</param> /// <returns>A new ticket note.</returns> public AccountNote CreateAccountNoteAs(long impersonateResourceId, long assignResourceId, DateTime startDateTime, DateTime endDateTime) { AccountNote retNote = null; Field[] fields = this.atwsServices.GetFieldInfo("AccountNote"); string actionTypeValue = PickListValueFromField(fields, "ActionType", "General"); AccountNote note = new AccountNote { id = 0, AccountID = 0, Note = "Test note created via impersonation", StartDateTime = startDateTime, EndDateTime = endDateTime, ActionType = actionTypeValue, AssignedResourceID = assignResourceId }; Entity[] entContact = { note }; this.atwsServices.AutotaskIntegrationsValue.ImpersonateAsResourceID = (int)impersonateResourceId; ATWSResponse respContact = this.atwsServices.create(entContact); if (respContact.ReturnCode > 0 && respContact.EntityResults.Length > 0) { retNote = (AccountNote)respContact.EntityResults[0]; } else { if (respContact.EntityReturnInfoResults.Length > 0) { throw new Exception("Could not create the Account Note: " + respContact.EntityReturnInfoResults[0].Message); } } return(retNote); }