How to alter singles value settings via REST API

I can obtain a Stock Setting with frappe.client.get_single_value like this :

curl -L -X GET '' \
-H 'Authorization: token 332badbadbad5982:09c7f3d0531fe2e' \
-H 'Content-Type: application/json' \
--data-raw '{
  "doctype": "Stock Settings",
  "field": "sample_retention_warehouse"

It returns:

    "message": "Batch Sample Restricted Area - LSSA"

I can find no corresponding frappe.client.set_single_value.
I did find frappe.client.set_value, but it requires an instance of a DocType to be specified.

Is there no way to do this?

Hi @MartinHBramwell,

I’m not aware of any RPC that does what you want, and the REST interface isn’t implemented for singletons. You could, of course, write your own set_single_value method and whitelist it (either in an app or via a custom server script). It’d be pretty simple to do, but I don’t think it’s there out of the box.

1 Like

Thanks for confirming my suspicions.

This may seem brutish, barbaric and pagan, but it gets the job done:

ssh erpnxt "mysql ${DB_Credentials} -e \"update tabSingles set value = 'Back Yard - LSSA' where doctype = 'Stock Settings' and field = 'default_warehouse'\"";

It’s a lower maintenance solution than a custom server script, imho.

1 Like