# Using Workflow and Developer SDK to update settings.  What are my validation errors?

**URL:** <https://community.dynatrace.com/t/using-workflow-and-developer-sdk-to-update-settings-what-are-my-validation-errors/48190>\
**Category:** Automations\
**Tags:** workflows, automations\
**Created:** [October 7, 2024, 3:24pm UTC](https://community.dynatrace.com/t/using-workflow-and-developer-sdk-to-update-settings-what-are-my-validation-errors/48190 "2024-10-07T15:24:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![HeadScratcher](https://avatars.discourse-cdn.com/v4/letter/h/85f322/32.png) [@HeadScratcher](https://community.dynatrace.com/u/HeadScratcher)\
**Post date:** [October 7, 2024, 3:24pm UTC](https://community.dynatrace.com/t/using-workflow-and-developer-sdk-to-update-settings-what-are-my-validation-errors/48190/1 "2024-10-07T15:24:02Z")

</div>

Hi I am creating a workflow to help manage our tenant.&nbsp; I want to find any Custom Logs at that environment scope and disable them if certain criteria are met.

I use the SDK to call get&nbsp; const res = await settingsObjectsClient.getSettingsObjects(params); successfully which gives me a list of custom logs and&nbsp; their objectIds

On my environment, I only have one test custom log source and it is disabled.

So using the I want to update the object IDs&nbsp; by enabling which I have chosen the method ettingsObjectsClient.putSettingsObjectByObjectId(config); but my code fails with some validation errors, as per below

Updating settings sandpit  
config  
{“schemaId”:“builtin:logmonitoring.custom-log-source-settings”,“schemaVersion”:“1.1”,“scope”:“environment”,“objectId”:“vu9U3hXa3xxxxxxxxxlYGG-71TeFdrerQ”,“updateToken”:“vu9UxxxxxxrQ”,“body”:{“value”:{“enabled”:true}}}  
error raised. 400: **Validation failed for 2 Validators.**

**2 questions**

What is wrong with my code?

How can I find out what the validation error might be referring to?

```javascript
import { settingsObjectsClient } from "@dynatrace-sdk/client-classic-environment-v2";

export default async function updateSettingsExample() 
{
  try{
    console.log("Updating settings");
    const config = { 
      schemaId: "builtin:logmonitoring.custom-log-source-settings",
      schemaVersion: "1.1",
      scope: "environment",
      objectId: 'vu9U3hXa3q0AAAABADBxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxidWlsdGluOlYzYtYTEyMi1iZGU1MzliNzJlMGG-71TeFdrerQ',
      updateToken: "vu9U3hxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxeFdjerQ",

      body: { 
        value: { 
            enabled: true,
          },
      },
    };

    console.log("config");
    console.log(JSON.stringify(config));
    const data = await settingsObjectsClient.putSettingsObjectByObjectId(config);
    console.log("result");
    console.log(JSON.stringify(data));
  }
  catch (error)         
  {
    console.log(`error raised. ${error}`);
  }
}

```

---

<div class="post-metadata">

**Author:** ![Fin\_Ubels](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/fin_ubels/32/18008_2.png) [@Fin\_Ubels](https://community.dynatrace.com/u/Fin_Ubels)\
**Post date:** [October 8, 2024, 3:27am UTC](https://community.dynatrace.com/t/using-workflow-and-developer-sdk-to-update-settings-what-are-my-validation-errors/48190/2 "2024-10-08T03:27:35Z")

</div>

Hey&nbsp;[@HeadScratcher](https://community.dynatrace.com/user/69708),

I have tested this in my own environment and it looks like you need to provide the entire value for the updated setting. For example, above you are only providing “enabled: true” when in actual fact you would also need to provide the rest of the log ingestion rule. You can find what needs to be included by using the API tab on the page as seen below.

 ![Fin_Ubels_1-1728357821556.png](https://global.discourse-cdn.com/dynatrace/original/3X/7/b/7b1741cfbb28ed9928cba66c0981f915b3ea9d21.png)

 ![Fin_Ubels_0-1728357749755.png](https://global.discourse-cdn.com/dynatrace/original/3X/9/c/9c1369ea7b0a98a0d0185d558fc2a3068f08e06b.png)

My code looked like:

```markup
import { settingsObjectsClient } from "@dynatrace-sdk/client-classic-environment-v2";

export default async function updateSettingsExample() 
{
  const data = 
    await settingsObjectsClient.putSettingsObjectByObjectId({
      objectId: "vu9U3hXa3q0AAAABADBidWlsdGluOmxvZ21vbml0b3JpbmcuY3VzdG9tLWxvZy1zb3VyY2Utc2V0dGluZ3MABnRlbmFudAAGdGVuYW50ACRkZTIxNmNiNi1kNmY1LTNhOWYtYmU2Ny03ZTQyMTYzNDc1MGG-71TeFdrerQ",
      body: { 
        value: {
          "enabled":false,"config-item-title":"Test","custom-log-source":{"type":"WINDOWS_EVENT_LOG","accept-binary":null,"values-and-enrichment":[{"path":"Test","enrichment":[]}]},"context":[]
        } 
      },
    });
}

```

Going back to your original requirement, you should have the value when you get the setting using “const res = await settingsObjectsClient.getSettingsObjects(params);” and then you should be able to modify what has returned and then just pass it back in “const data = await settingsObjectsClient.putSettingsObjectByObjectId(config);”.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![HeadScratcher](https://avatars.discourse-cdn.com/v4/letter/h/85f322/32.png) [@HeadScratcher](https://community.dynatrace.com/u/HeadScratcher)\
**Post date:** [October 8, 2024, 10:37am UTC](https://community.dynatrace.com/t/using-workflow-and-developer-sdk-to-update-settings-what-are-my-validation-errors/48190/3 "2024-10-08T10:37:56Z")

</div>

Thanks&nbsp;[@Fin\_Ubels](https://community.dynatrace.com/user/47376)&nbsp; I understand what you are saying that does make sense so&nbsp; I&nbsp; will try and get that working in the next couple of days.

Extra points for mentioning the API info.&nbsp; I always forget about that but it is hugely useful when using the API.

---

<div class="post-metadata">

**Author:** ![HeadScratcher](https://avatars.discourse-cdn.com/v4/letter/h/85f322/32.png) [@HeadScratcher](https://community.dynatrace.com/u/HeadScratcher)\
**Post date:** [October 8, 2024, 3:56pm UTC](https://community.dynatrace.com/t/using-workflow-and-developer-sdk-to-update-settings-what-are-my-validation-errors/48190/4 "2024-10-08T15:56:53Z")

</div>

So&nbsp;[@Fin\_Ubels](https://community.dynatrace.com/user/47376)&nbsp; I eventually got this working as you suggested.&nbsp; &nbsp;It took me ages to get the JSON object copy just right.&nbsp; &nbsp; Am I right in thinking this can be developed in VS Code or some other humane IDE ?
