Update

Updating a record is accomplished by sending a HTTP PUT to the appropriate URL. The form of the URL requires knowledge of the record ID being updated. If the record ID is not known, then it must be looked up using the list action. The payload of the PUT needs to only contain the fields that are to be changed. The contents of the payload must meet the model requirements otherwise an error will be thrown. Consider the following example where the first name associated with account ID 36 is being updated via XML:

curl -i -X PUT -H 'Content-Type: application/xml'
 -d '<?xml version="1.0"?><record><first-name>Alfred</first-name></record>'
 https://rxg.dns/admin/scaffolds/accounts/update/36.xml?api_key=WR5...KLw

or via JSON: curl -i -X PUT -H 'Content-Type: application/json' -d '{"record": {"first_name": "Anson"}}' https://rxg.dns/admin/scaffolds/accounts/update/36.xml?api_key=WR5...KLw If the request is successful the rXg responds with a HTTP/1.1 200 OK: ``` HTTP/1.1 200 OK Content-Type: application/xml; charset=utf-8 X-UA-Compatible: IE=Edge,chrome=1 ETag: "6189032e56e827aafd5543357368d300" Cache-Control: max-age=0, private, must-revalidate Set-Cookie: _rxg_console_session=BAh...66d; path=/; HttpOnly X-Request-Id: de794ed53142ffc00c9e5c135716edfc X-Runtime: 0.062918 Date: Thu, 14 Jun 2012 01:07:10 GMT X-Rack-Cache: invalidate, pass Connection: close Server: thin 1.3.1 codename Triple Espresso

<?xml version="1.0" encoding="UTF-8"?> 2012-05-28T14:55:57-04:00 apikeytest y/j0nSYiWmwho4X8jj0symrxccU= [email protected] Alfred 36 test 5 restfulapitest true dcfae2f069cb8167972225ba7c33d6ac5642fd2a active true true true 2012-06-13T21:07:10-04:00 apikeytest If the request fails, then the rXg responds with an HTTP error code, usually HTTP/1.1 422. For, example, if an invalid first name is passed in: curl -i -X PUT -H 'Content-Type: application/xml' -d '<?xml version="1.0"?>a' https://rxg.dns/admin/scaffolds/accounts/update/36.xml?api_key=WR5...KLw The response would be: HTTP/1.1 422 Content-Type: application/xml; charset=utf-8 X-UA-Compatible: IE=Edge,chrome=1 Cache-Control: no-cache Set-Cookie: _rxg_console_session=BAh...1f6 X-Runtime: 0.041413 Date: Thu, 14 Jun 2012 01:18:57 GMT X-Rack-Cache: invalidate, pass Connection: close Server: thin 1.3.1 codename Triple Espresso

<?xml version="1.0" encoding="UTF-8"?> First name is too short (minimum is 2 characters) ```


Cookies help us deliver our services. By using our services, you agree to our use of cookies.