简体   繁体   中英

Unable to get embed token of power bi report in php after successfully generating its access token

I am using get/post request to generate embed token of the powerbi report in php and i successfully generated the access token by following the example given in this link https://community.powerbi.com/t5/Developer/How-To-Get-embed-token-using-Get-Post-only/td-p/294475 but when i used this access token to generate embed token for me it returns empty array in response.This is my code

$headers = array(
    "Authorization: Bearer <acesstoken generated>"
);

$url = 'https://api.powerbi.com/v1.0/myorg/groups/<group-id>/reports/<report-id>/GenerateToken';
$post_params = array(
    'accessLevel' => 'View',
    'datasetId'=>'<dataset-id>'     
);

$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $post_params);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER,$headers );

curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec( $ch );
echo $response;

Any help would be appreciated thanks.

After the hardwork of 1 day I finally figured out i was using application id in the resource param for generating access token instead of this https://analysis.windows.net/powerbi/api link. So when i used this link ,the problem is solved and generated the embed token successfully.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM