<?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 401 (Unauthorized) when calling UpsertGoalCurrentValueConnection() API in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/401-Unauthorized-when-calling-UpsertGoalCurrentValueConnection/m-p/2510566#M36060</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to make the following request:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;    $api = "api.powerbi.com"
    $response = Invoke-WebRequest `
        -Method Post `
        -Uri "https://$api/v1.0/myOrg/internalScorecards($scorecardId)/goals($($currentGoal.id))/UpsertGoalCurrentValueConnection()" `
        -Body ($query) `
        -ContentType "application/json" `
        -Headers @{ "Authorization" = "Bearer $token" }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but I'm getting a 401 (Unauthorized) response.&lt;BR /&gt;I get my token like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$api = "api.powerbi.com"
Login-PowerBI
$bearer = (Get-PowerBIAccessToken)["Authorization"]
$token = $bearer.SubString(6, $bearer.Length - 6)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I get authorization to use this api?&lt;/P&gt;</description>
    <pubDate>Thu, 12 May 2022 12:35:39 GMT</pubDate>
    <dc:creator>Popopop</dc:creator>
    <dc:date>2022-05-12T12:35:39Z</dc:date>
    <item>
      <title>401 (Unauthorized) when calling UpsertGoalCurrentValueConnection() API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/401-Unauthorized-when-calling-UpsertGoalCurrentValueConnection/m-p/2510566#M36060</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to make the following request:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;    $api = "api.powerbi.com"
    $response = Invoke-WebRequest `
        -Method Post `
        -Uri "https://$api/v1.0/myOrg/internalScorecards($scorecardId)/goals($($currentGoal.id))/UpsertGoalCurrentValueConnection()" `
        -Body ($query) `
        -ContentType "application/json" `
        -Headers @{ "Authorization" = "Bearer $token" }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but I'm getting a 401 (Unauthorized) response.&lt;BR /&gt;I get my token like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$api = "api.powerbi.com"
Login-PowerBI
$bearer = (Get-PowerBIAccessToken)["Authorization"]
$token = $bearer.SubString(6, $bearer.Length - 6)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I get authorization to use this api?&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 12:35:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/401-Unauthorized-when-calling-UpsertGoalCurrentValueConnection/m-p/2510566#M36060</guid>
      <dc:creator>Popopop</dc:creator>
      <dc:date>2022-05-12T12:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: 401 (Unauthorized) when calling UpsertGoalCurrentValueConnection() API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/401-Unauthorized-when-calling-UpsertGoalCurrentValueConnection/m-p/2516803#M36122</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/389091"&gt;@Popopop&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Please update the code as below when get the token and check if it can resolve the problem...&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;$api = "api.powerbi.com"
Login-PowerBI
$bearer = (Get-PowerBIAccessToken)["Authorization"]
$token = $bearer.SubString(7, $bearer.Length - 7)&lt;/LI-CODE&gt;
&lt;P&gt;In addition, please review the following blog. Hope it can help you.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/Power-BI-Goals-Pro-Tip-Take-over-goal-connections-in-a-scorecard/ba-p/2181892" target="_self"&gt;&lt;SPAN&gt;Power BI Goals Pro Tip: Take over goal connections in a scorecard&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yingyinr_0-1652688222426.png" style="width: 999px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/715487iFB65A97BDC11F6D2/image-size/large?v=v2&amp;amp;px=999" role="button" title="yingyinr_0-1652688222426.png" alt="yingyinr_0-1652688222426.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2022 08:04:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/401-Unauthorized-when-calling-UpsertGoalCurrentValueConnection/m-p/2516803#M36122</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-05-16T08:04:01Z</dc:date>
    </item>
    <item>
      <title>Re: 401 (Unauthorized) when calling UpsertGoalCurrentValueConnection() API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/401-Unauthorized-when-calling-UpsertGoalCurrentValueConnection/m-p/2516850#M36123</link>
      <description>&lt;P&gt;Hi, this doesn't solve the problem.&lt;BR /&gt;For the record, in the same script I execute this with the token I get (both with the code written in my original post and both with the two methods you suggested me), and this works with no problem:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$response = Invoke-WebRequest -Uri "https://$api/v1.0/myorg/groups/{$groupId}/scorecards($scorecardId)/goals" -Headers @{ "Authorization" = "Bearer $token" }
$scorecard = $response.Content | ConvertFrom-Json&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So it's that request in particular that doesn't work.&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2022 08:18:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/401-Unauthorized-when-calling-UpsertGoalCurrentValueConnection/m-p/2516850#M36123</guid>
      <dc:creator>Popopop</dc:creator>
      <dc:date>2022-05-16T08:18:32Z</dc:date>
    </item>
  </channel>
</rss>

