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

83 views Asked by At

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?

3

There are 3 answers

0
Kafo On BEST ANSWER

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.

1
Tomas Petricek On

Based on a similar StackOverflow question, it looks like you might get this error when there is something else wrong in your request, such as when it is missing the appropriate Content-Type.

I'm not familiar with Highrise or Restsharp to give a definite answer, but it seems that there might be something wrong with how you create the request. Just from reading your code, I find the use of AddParameter to add the body somewhat unexpected (even though it might be right). It looks like you might be able to use AddBody instead, so I'd try that.

(This is more of a comment than a proper answer, but it got too long to post it as a comment!)

0
Joshua Rowlison On

I believe this is a result of attempting to add tags while creating the user. It's not at all clear from the API but at least in my experience no formulation of the tags field can be submitted with a company/person and succeed.

Alternatively, and I don't speak f# so I can't be sure, but the "Content-Type" is supposed to be in headers. Does the parameter component you're using add that explicitly as a header?

The missing name field showed up for me before I got the header working.