Search code examples
f#restsharphighrise

HighRise API Create a person failing with missing first name while it's there


I'm trying to create a person in highrise using the API. I'm getting a "First name is missing. Contacts must have a name" error message in the response.

Here is my code:

let x = """<?xml version="1.0" encoding="UTF-8"?>
<person>
  <first-name>name</first-name>
  <last-name>last</last-name>
  <contact-data>
    <email-addresses type="array">
      <email-address>
        <address>[email protected]</address>
      </email-address>
    </email-addresses>
  </contact-data>
  <tags type="array">
    <tag>
      <id type="integer">6154219</id>
      <name>sometag</name>
    </tag>
  </tags>
</person>"""

let req = new RestRequest("/people.xml", Method.POST)
req.AddParameter("Content-Type", "application/xml")
req.AddParameter("application/xml", x, ParameterType.RequestBody)
let res = client.Execute(req) 

The response returns a 422 Status code. Not sure what I'm doing wrong here?


Solution

  • Turns out that you cannot add tags when creating a new person. It needs to added in a separate request after adding a contact. This is not explicitly mentioned in the documentation but can be concluded from their examples.