PowerBI get report id with java API response returning 401

Olga Fedorova | Solgar Vitamin RU 0 Reputation points
2025-04-11T14:58:08.67+00:00

While attempting to retrieve the report ID from the URL api.powerbi.com/v1.0/myorg/reports/ using my Java API, I encountered an HTTP 401 error in the response.

Despite granting all necessary permissions (DashBoard,DataSet,report,tenant, workspace)in the App Registrations menu in Azure AD, I am unable to resolve the issue. I will be very glad to help solve the issue!

// Construct the URL to query the workspace reports

    String url1 = "https://api.powerbi.com/v1.0/myorg/admin/groups/";

    String url2 = "/reports";

    String url = url1 + workspaceID + url2;

    // Prepare the HTTP request

    HttpClient httpClient = HttpClient.newBuilder()

            .connectTimeout(Duration.ofSeconds(10))

            .build();

    HttpRequest request = HttpRequest.newBuilder()

            .uri(URI.create(url))

            .header("Authorization", "Bearer " + token)

            .header("Content-Type", "application/json")

            .GET() // Since we're performing a GET request

            .build();

    // Send the request and handle the response

    HttpResponse
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
43,274 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.