Creating appointment using REST

Hi,

I am trying to use the REST API to create an appointment. I could do that but unfortunately I could not find a way to assign a contact to the newly created appointment. The REST API specification does not mention anything about a contact id in the appointments endpoint. Is it possible to create an appointment associated to a contact using API calls.

Thanks,
Sorin.

That is interesting and you are correct, there doesn’t seem to be a contact assignment. @martinc may be able to point this out to someone or someone else might have more info than I do. In the mean time you could still accomplish this with the api (using the same OAuth token you’re using for REST)

Our development team has been made aware of this change request.
Currently instead of using the REST API the XML API can be used to add an appointment with a contact through the “ContactAction” Table.

1 Like

I tried to do this but it seems that the ContactAction table field called “ObjectType” is not writable via XML. The documentation says that is a read-only field. The default value for this field is Note. So we can only create Notes using the XML ContactAction table.

It seems that the current API functionality would not allow creating Appointments assigned to specified contacts. Neither REST not XML APIs would work.

You don’t need object type to create an appointment and not all fields are required. Are you setting isAppointment to 1?

@Robert_Howard, if you provide a value for EndDate and omit a value for CompletionDate the record should be saved as an appointment instead of a note.

2 Likes

I tried to do this. When we omitted the CompletionDate the API accepted the request but no appointment was displayed in the contact’s profile page. When we set a value for CompletionDate a note was created instead.

Can you send an example of an XML request that would correctly create an appointment.

Please find below the request we sent.

<?xml version="1.0" encoding="UTF-8"?>DataService.addxxxxContactActionActionTypeAppointmentActionDescriptionContact Science Appointment for Suspect Stefan Constantin in Cycle One Cycle. Latest comment for Suspect was: CreationNotesContact Science Appointment Scheduled- Stefan Constantin, XSoft ContactId5IsAppointment1EndDate2017-08-08T11:45:00.00ZAccepted1LocationActionDate2017-08-08T11:15:00.00Z

Thanks,
Sorin.

@Robert_Howard Here’s an example request. I mistakenly didn’t mention that IsAppointment=1 is also required.

<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
  <methodName>DataService.add</methodName>
  <params>
    <param>
      <value>
        <string>{{privateKey}}</string>
      </value>
    </param>
    <param>
      <value>
        <string>ContactAction</string>
      </value>
    </param>
    <param>
      <value>
        <struct>
          <member>
            <name>ContactId</name>
            <value>3266</value>
          </member>
          <member>
            <name>ActionDescription</name>
            <value>Example Xml-Rpc Appointment</value>
          </member>
          <member>
            <name>IsAppointment</name>
            <value>1</value>
          </member>
          <member>
          	<name>ActionDate</name>
          	<value><dateTime.iso8601>20170803T08:00:00</dateTime.iso8601></value>
          </member>
          <member>
            <name>EndDate</name>
            <value><dateTime.iso8601>20170803T10:00:00</dateTime.iso8601></value>
          </member>
          <member>
            <name>UserID</name>
            <value>1</value>
          </member>
        </struct>
      </value>
    </param>
  </params>
</methodCall>
3 Likes

You just saved me from wasting my more precious time !

Glad I could help!