Question

i´m playing arround with the HIGHRISE API, and they understood the meaning of rest, its pretty cool and at some points gracefully forgivingly, but

has anybody any idea why the xml i PUT is not accepted ?

here is some relevant logging :

2014-02-23 00:00:04] app.INFO: Updating:Person:Highrise-API =  people/11834527375.xml [] []
[2014-02-23 00:00:04] app.INFO: request body is :

<?xml version="1.0" encoding="UTF-8"?>
<person>
  <first-name><![CDATA[Johnny]]></first-name>
  <last-name><![CDATA[B. Good]]></last-name>
  <visible-to><![CDATA[Everyone]]></visible-to>
  <subject_datas type="array">
    <subject_data>
      <subject_field_id type="integer"><![CDATA[43212]]></subject_field_id>
      <value><![CDATA[dsa328394OOKD323H]]></value>
    </subject_data>
    <subject_data>
      <subject_field_id type="integer"><![CDATA[470259]]></subject_field_id>
      <value><![CDATA[provider://w184071823/fmdks/2032]]></value>
    </subject_data>
    <subject_data>
      <subject_field_id type="integer"><![CDATA[469130]]></subject_field_id>
      <value><![CDATA[CORE]]></value>
    </subject_data>
    <subject_data>
      <subject_field_id type="integer"><![CDATA[469132]]></subject_field_id>
      <value><![CDATA[Way too cool]]></value>
    </subject_data>
  </subject_datas>
  <contact-data>
    <phone-numbers>
      <phone-number type="array">
        <number><![CDATA[081 6418273]]></number>
        <location><![CDATA[Work]]></location>
      </phone-number>
    </phone-numbers>
    <addresses type="array">
      <address>
        <city><![CDATA[New York City]]></city>
        <country><![CDATA[US]]></country>
        <state><![CDATA[New York]]></state>
        <street><![CDATA[Siplingerstreet 11]]></street>
        <zip><![CDATA[87527]]></zip>
        <location><![CDATA[Work]]></location>
      </address>
    </addresses>
  </contact-data>
</person>
 [] []
[2014-02-23 00:00:04] app.INFO: request set [] []
[2014-02-23 00:00:04] app.ERROR: Guzzle/3.8.1 curl/7.28.1 PHP/5.4.10 - [2014-02-22T23:00:04+00:00] "PUT /people/11834527375.xml HTTP/1.1" 422 103 [] []
[2014-02-23 00:00:04] app.INFO: Caught client-error-exception in HighriseService updatePerson(): exception 'Guzzle\Http\Exception\ClientErrorResponseException' with message 'Client error response
[status code] 422
[reason phrase] Unprocessable Entity

i dont see the error :/ I´m very sure the subject_field_id´s are correct and those custom fields are set Posting e.g saving that xml works, i saw from the response that are fields were set,

only thing i can guess is, that i´m trying to PUT a version where nothing has changed, is that the problem ?

because my code only checks if that person exists at all and if so update it instead of creating

Was it helpful?

Solution

You should get back some XML in the body of the response. It should look like this:

<?xml version="1.0" encoding="UTF-8"?>
<errors>
  <error>Phone number '555-555-5555' has already been taken</error>
</errors>

If you include the id for the existing phone number in your PUT request, then we know that you want to update the existing address, rather than adding a new one: https://github.com/basecamp/highrise-api/blob/master/sections/people.md#update-person

Contact data and Subject data that include an id will be updated, data that doesn’t will be assumed to be new and created from scratch. To remove a piece of data, prefix its id with a minus sign (e.g. -1).

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