Jump to content

Featured Replies

Posted

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:

 

rawProperties

array

Key => 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 by bernhara

Solved by bernhara

Go to solution
  • bernhara changed the title to Changing the "birthday" property using the API: unable to find the right syntax
  • Community Expert

There are 3 integer fields in the table for the birthday:

  • bday_day

  • bday_month

  • bday_year

If you need other fields, you can just look up the names inside the core_members table directly.

  • 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.

  • 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.json

Search 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 by teraßyte
typo

  • 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;

}

}

  • Author
  • Solution
 

There are 3 integer fields in the table for the birthday:

  • bday_day

  • bday_month

  • bday_year

Looking 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'

Recently Browsing 0

  • No registered users viewing this page.