Quantcast
Channel: Developer topics
Viewing all articles
Browse latest Browse all 17881

Powerbi api create dataset http respond Forbidden 403

$
0
0

Help , i use php creat dataset send request but http respond 403 i can't creat dataset on my powerbi 

<?php
session_start();
$token = $_GET['code'];
$session_state = $_GET['session_state'];
$tablename = $_SESSION['CustomerId'];
$columns[] = array(
'name'=>'PorductID',
'type'=>'Text',
);
$columns[] = array(
'name'=>'Name',
'type'=>'Text',
);
$columns[] = array(
'name'=>'Number',
'type'=>'Number',
);
$columns[] = array(
'name'=>'Price',
'type'=>'Number',
);
$columns[] = array(
'name'=>'MenuId',
'type'=>'Text',
);
$columns[] = array(
'name'=>'PurchaseTime',
'type'=>'DateTime',	
);
$table = array(
'name'=>$tablename,
'columns'=>	$columns,
);
$data = array(
'name'=>'Client',
'table'=>$table,
);
$data = utf8_encode(json_encode($data));
$url ="https://api.powerbi.com/v1.0/myorg/datasets";
// build datasets , reference information https://powerbi.microsoft.com/zh-tw/documentation/powerbi-developer-walkthrough-push-data-create-dataset/
$header[] ="ContentLength:0";
$header[] ="Content-Type:application/json";
$headr[] = "Authorization:$token";
$ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $url);
      curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
	  curl_setopt($ch,CURLOPT_FORBID_REUSE ,true);
	  curl_setopt($ch, CURLOPT_POST, true);
	  curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
	  $output = curl_exec($ch);
      $error = curl_error($ch);
      $http = curl_getinfo($ch,CURLINFO_HTTP_CODE);
	  curl_close($ch);
	  echo $http;
      if($http>300){
		  exit('操作失敗');
	  }
	  echo$output;

?>

Viewing all articles
Browse latest Browse all 17881

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>