Question

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 => "charlie@222.com")

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 => "charlie@222.com"}})

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

Was it helpful?

Solution

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 => "charlie@222.com"}
      }]
    }
  )

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top