<?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 Not found exception trying to create a token in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Not-found-exception-trying-to-create-a-token/m-p/3262368#M42891</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I'm trying to use the embedded token but without any luck, i already create an app registration, i created a embedded capacity to test, get all API permission and the azure admin granted those permission, but i still have the not found exception when i try to create the token via C#&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Microsoft.Rest.HttpOperationException: Operation returned an invalid status code 'NotFound'&lt;BR /&gt;at Microsoft.PowerBI.Api.ReportsOperations.&amp;lt;GenerateTokenInGroupWithHttpMessagesAsync&amp;gt;d__32.MoveNext()&lt;BR /&gt;--- End of stack trace from previous location where exception was thrown ---&lt;BR /&gt;at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)&lt;BR /&gt;at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&lt;BR /&gt;at Microsoft.PowerBI.Api.ReportsOperationsExtensions.&amp;lt;GenerateTokenInGroupAsync&amp;gt;d__87.MoveNext()&lt;BR /&gt;--- End of stack trace from previous location where exception was thrown ---&lt;BR /&gt;at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)&lt;BR /&gt;at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&lt;BR /&gt;at Microsoft.PowerBI.Api.ReportsOperationsExtensions.GenerateTokenInGroup(IReportsOperations operations, Guid groupId, Guid reportId, GenerateTokenRequest requestParameters)&lt;BR /&gt;at EmbedAPISample.Program.Main(String[] args) in E:\Testes de Codigo\CSharp\PowerBI\Token\Embed-API-Sample\EmbedAPISample\Program.cs:line 53&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;C# code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using Microsoft.IdentityModel.Clients.ActiveDirectory;
using Microsoft.PowerBI.Api;
using Microsoft.PowerBI.Api.Models;
using Microsoft.Rest;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace EmbedAPISample
{
    class Program
    {
        private static bool useEmbedToken = true;
        private static bool useRLS = false;

        private static string authorityUrl = "https://login.microsoftonline.com/organizations/"; 
        private static string resourceUrl = "https://analysis.windows.net/powerbi/api";
        private static string apiUrl = "https://api.powerbi.com/";

        private static string tenantId = "i put my tenant id here";
        private static Guid groupId = Guid.Parse("i put my group id here");
        
        private static Guid reportId = Guid.Parse("i put my report id here");
        private static Guid datasetId = Guid.Parse("i put my dataset id here"); 

        // **** Update the Client ID and Secret within Secrets.cs ****

        private static ClientCredential credential = null;
        private static AuthenticationResult authenticationResult = null;
        private static TokenCredentials tokenCredentials = null;

        static void Main(string[] args)
        {

            try
            {
                // Create a user password cradentials.
                credential = new ClientCredential(Secrets.ClientID, Secrets.ClientSecret);

                // Authenticate using created credentials
                Authorize().Wait();

                using (var client = new PowerBIClient(new Uri(apiUrl), tokenCredentials))
                {&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What i'm doing wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Wed, 31 May 2023 16:48:43 GMT</pubDate>
    <dc:creator>Igorvf83</dc:creator>
    <dc:date>2023-05-31T16:48:43Z</dc:date>
    <item>
      <title>Not found exception trying to create a token</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Not-found-exception-trying-to-create-a-token/m-p/3262368#M42891</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I'm trying to use the embedded token but without any luck, i already create an app registration, i created a embedded capacity to test, get all API permission and the azure admin granted those permission, but i still have the not found exception when i try to create the token via C#&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Microsoft.Rest.HttpOperationException: Operation returned an invalid status code 'NotFound'&lt;BR /&gt;at Microsoft.PowerBI.Api.ReportsOperations.&amp;lt;GenerateTokenInGroupWithHttpMessagesAsync&amp;gt;d__32.MoveNext()&lt;BR /&gt;--- End of stack trace from previous location where exception was thrown ---&lt;BR /&gt;at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)&lt;BR /&gt;at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&lt;BR /&gt;at Microsoft.PowerBI.Api.ReportsOperationsExtensions.&amp;lt;GenerateTokenInGroupAsync&amp;gt;d__87.MoveNext()&lt;BR /&gt;--- End of stack trace from previous location where exception was thrown ---&lt;BR /&gt;at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)&lt;BR /&gt;at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&lt;BR /&gt;at Microsoft.PowerBI.Api.ReportsOperationsExtensions.GenerateTokenInGroup(IReportsOperations operations, Guid groupId, Guid reportId, GenerateTokenRequest requestParameters)&lt;BR /&gt;at EmbedAPISample.Program.Main(String[] args) in E:\Testes de Codigo\CSharp\PowerBI\Token\Embed-API-Sample\EmbedAPISample\Program.cs:line 53&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;C# code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using Microsoft.IdentityModel.Clients.ActiveDirectory;
using Microsoft.PowerBI.Api;
using Microsoft.PowerBI.Api.Models;
using Microsoft.Rest;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace EmbedAPISample
{
    class Program
    {
        private static bool useEmbedToken = true;
        private static bool useRLS = false;

        private static string authorityUrl = "https://login.microsoftonline.com/organizations/"; 
        private static string resourceUrl = "https://analysis.windows.net/powerbi/api";
        private static string apiUrl = "https://api.powerbi.com/";

        private static string tenantId = "i put my tenant id here";
        private static Guid groupId = Guid.Parse("i put my group id here");
        
        private static Guid reportId = Guid.Parse("i put my report id here");
        private static Guid datasetId = Guid.Parse("i put my dataset id here"); 

        // **** Update the Client ID and Secret within Secrets.cs ****

        private static ClientCredential credential = null;
        private static AuthenticationResult authenticationResult = null;
        private static TokenCredentials tokenCredentials = null;

        static void Main(string[] args)
        {

            try
            {
                // Create a user password cradentials.
                credential = new ClientCredential(Secrets.ClientID, Secrets.ClientSecret);

                // Authenticate using created credentials
                Authorize().Wait();

                using (var client = new PowerBIClient(new Uri(apiUrl), tokenCredentials))
                {&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What i'm doing wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 16:48:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Not-found-exception-trying-to-create-a-token/m-p/3262368#M42891</guid>
      <dc:creator>Igorvf83</dc:creator>
      <dc:date>2023-05-31T16:48:43Z</dc:date>
    </item>
  </channel>
</rss>

