How to add a Person using the Highrise Ruby gem?

555 views Asked by At

I am trying to use https://github.com/tapajos/highrise/ to update user accounts when people sign up to an app. However I am not getting very far.

In console I am doing:

person = Highrise::Person.create(:name => "charlie")

Which saves fine, but if I do something like

person = Highrise::Person.create(:name => "charlie", :email => "[email protected]")

then I get:

Unprocessable Entity

I can not get my head around this, I essentially want to add a full record:

person = Highrise::Person.create(:name => "charlie", :params => {:contact_data => {:email_addresses => "[email protected]"}})

but still i get the same error and can not find any examples online

1

There are 1 answers

0
Jeff Schuil On BEST ANSWER

You were on the right track with that last attempt. Give this a try:

person = Highrise::Person.create(
    :first_name => "Charlie", :last_name => "Bravo",
    :contact_data => {
      :email_addresses => [{
        :email_address => {:address => "[email protected]"}
      }]
    }
  )

This matches the structure of the create a person request, as defined in the Highrise API. https://github.com/37signals/highrise-api/blob/master/sections/people.md#create-person

Also you can refer to ruby api's test spec for more examples https://github.com/tapajos/highrise/blob/f44cb3212c6d49549330c46454fe440ac117fa1b/spec/highrise/person_spec.rb#L40