Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted February 19Feb 19 I would like to update the "birthday" property of some members using the API.I managed to update the properties which can be changed by passing a direct argument to the API call, like the "name" property for example: curl -u <API_KEY>: 'https://<BASE URL>/api/core/members/<MEMBER ID>' --data 'name=titi_test_api2'To update the "birthday" property, the documentation says that I should use the "rawProperties" argument: rawPropertiesarrayKey => value object of member properties to set. Note that values will be set exactly as supplied without validation. USE AT YOUR OWN RISK.But I could not guess the correct syntax to provide as an acceptable value for "rawProperties" .May I have an example? Edited February 19Feb 19 by bernhara
February 19Feb 19 Community Expert There are 3 integer fields in the table for the birthday:bday_daybday_monthbday_yearIf you need other fields, you can just look up the names inside the core_members table directly.
February 19Feb 19 Author look up the names inside the core_members table😉I would say "of course".But we are hosted on a Invision provided Cloud instance. So, I've no access to the DB.
February 19Feb 19 Community Expert 😉I would say "of course".But we are hosted on a Invision provided Cloud instance. So, I've no access to the DB.Ahh, okay. I keep forgetting about the Cloud. IPS should provide a way to get alist of those fields in the ACP API reference guide then. 🤔As a temporary workaround, you can look up the schema.json file of the core application. by adding /applications/core/data/schema.json to your site URL.For example, for this site, it would be: https://invisioncommunity.com/applications/core/data/schema.jsonSearch for the core_members table name, and you can get a list of all the default columns in it. Here's the birthday columns for example: "bday_day": { "allow_null": true, "auto_increment": false, "binary": false, "comment": "", "decimals": null, "default": null, "length": 2, "name": "bday_day", "type": "INT", "unsigned": false, "values": [], "zerofill": false }, "bday_month": { "allow_null": true, "auto_increment": false, "binary": false, "comment": "", "decimals": null, "default": null, "length": 2, "name": "bday_month", "type": "INT", "unsigned": false, "values": [], "zerofill": false }, "bday_year": { "allow_null": true, "auto_increment": false, "binary": false, "comment": "", "decimals": null, "default": null, "length": 4, "name": "bday_year", "type": "INT", "unsigned": false, "values": [], "zerofill": false }, Edited February 19Feb 19 by teraßyte typo
February 19Feb 19 Author FYI, I found the PHP code which handles the request: if( isset( \IPS\Request::i()->rawProperties ) AND \is_array( \IPS\Request::i()->rawProperties ) ) { foreach( \IPS\Request::i()->rawProperties as $property => $value ) { $member->$property = \is_numeric( $value ) ? (int) $value : $value; } }
February 22Feb 22 Author Solution There are 3 integer fields in the table for the birthday:bday_daybday_monthbday_yearLooking at the systems logs which can be accessed on the Cloud instance, I could read the stack trace and see how my curl call had been interpreted.Based on the information you gave me👍, I could build a working curl command: curl -u <API_KEY>: 'https://<BASE URL>/api/core/members/<MEMBER ID>' --data 'rawProperties[bday_year]=1962' --data 'rawProperties[bday_day]=1' --data 'rawProperties[bday_month]=4'