<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Change settings via API using powershell in Dynatrace API</title>
    <link>https://community.dynatrace.com/t5/Dynatrace-API/Change-settings-via-API-using-powershell/m-p/245168#M3101</link>
    <description>&lt;P&gt;Hi, Thanks for your reply and for mentioning about the API token. I used a GET example for validating the authentication part, then I forgot to amend the token when i was testing the POST scenario. Now I am able to execute the script, but I had to use my original setting, it didn't work with just 'Api-Token $Token'.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"Authorization" = 'Api-Token' + ' ' + $Token&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 09 May 2024 10:04:21 GMT</pubDate>
    <dc:creator>Mario_DT</dc:creator>
    <dc:date>2024-05-09T10:04:21Z</dc:date>
    <item>
      <title>Change settings via API using powershell</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-API/Change-settings-via-API-using-powershell/m-p/245113#M3099</link>
      <description>&lt;P&gt;Hello Community,&lt;/P&gt;
&lt;P&gt;I am trying to set the monitoring mode for a specific host using API with powershell. With cURL was very easy, with Powershell i am struggling. I have created the script below, but i get the following error:&lt;/P&gt;
&lt;P&gt;Invoke-RestMethod : {"error":{"code":403,"message":"Token is missing required scope. Use one of: settings.write (Write&lt;BR /&gt;settings)"}}&lt;/P&gt;
&lt;P&gt;Unfortunately, I didn't manage to find an example with a POST using Powershell.&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Mario&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;$Token = 'dt0c01.RM2ATDEG5773MBHGFGHDFGDFGHDGHKFDGHFDGHFDGFDGFDGHDFKDGHDHGDFGDGDGHDGHDG'&lt;/P&gt;
&lt;P&gt;$Body = @{&lt;BR /&gt;schemaId = 'builtin:host.monitoring.mode'&lt;BR /&gt;schemaVersion = '1.3'&lt;BR /&gt;scope = 'HOST-5F30AHGJHKGHJGHK'&lt;BR /&gt;value = @{&lt;BR /&gt;monitoringMode = 'FULL_STACK'&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;$Params = @{&lt;BR /&gt;Uri = '&lt;A href="https://{environmentid}.live.dynatrace.com/api/v2/settings/objects" target="_blank" rel="noopener"&gt;https://{environmentid}.live.dynatrace.com/api/v2/settings/objects&lt;/A&gt;'&lt;BR /&gt;Method = 'POST'&lt;BR /&gt;Body = '[' + ($Body | ConvertTo-Json) + ']'&lt;BR /&gt;Headers = @{&lt;BR /&gt;"Content-Type" = 'application/json; charset=utf-8'&lt;BR /&gt;"Authorization" = 'Api-Token' + ' ' + $Token&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;Invoke-RestMethod @Params&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2024 07:31:43 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-API/Change-settings-via-API-using-powershell/m-p/245113#M3099</guid>
      <dc:creator>Mario_DT</dc:creator>
      <dc:date>2024-05-09T07:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: Change settings via API using powershell</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-API/Change-settings-via-API-using-powershell/m-p/245127#M3100</link>
      <description>&lt;P&gt;Your answer is in the error message. The token you are using needs to have the "settings.write" scope. You need to get another token with that scope.&lt;/P&gt;&lt;P&gt;You can also omit the '+' in your Authorization header for easier reading and just do&lt;/P&gt;&lt;P&gt;"Authorization" = "Api-Token $Token"&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2024 20:02:58 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-API/Change-settings-via-API-using-powershell/m-p/245127#M3100</guid>
      <dc:creator>cbaldi</dc:creator>
      <dc:date>2024-05-08T20:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: Change settings via API using powershell</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-API/Change-settings-via-API-using-powershell/m-p/245168#M3101</link>
      <description>&lt;P&gt;Hi, Thanks for your reply and for mentioning about the API token. I used a GET example for validating the authentication part, then I forgot to amend the token when i was testing the POST scenario. Now I am able to execute the script, but I had to use my original setting, it didn't work with just 'Api-Token $Token'.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"Authorization" = 'Api-Token' + ' ' + $Token&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2024 10:04:21 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-API/Change-settings-via-API-using-powershell/m-p/245168#M3101</guid>
      <dc:creator>Mario_DT</dc:creator>
      <dc:date>2024-05-09T10:04:21Z</dc:date>
    </item>
  </channel>
</rss>

