Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
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;
?>
Solved! Go to Solution.
What is the $token like in your case? it should be something like "Bearer tokenstring". You can test the REST API alone via POSTMAN.
$token = $_GET['code']; . . $headr[] = "Authorization:$token";
session_start();
$access = $this->token();
$token_type = $access->token_type;
$token = $access->access_token;
date_default_timezone_set('UTC');
$date = date('D , d M Y H:i:s');
//Sun, 20 Sep 2009 20:36:40 GMT
$tablename = 'info';
$columns[] = array(
'name'=>'Number',
'dataType'=>'Int64',
);
$columns[] = array(
'name'=>'ClinetId',
'dataType'=>'Int64',
);
$columns[] = array(
'name'=>'Price',
'dataType'=>'Int64',
);
$columns[] = array(
'name'=>'MenuId',
'dataType'=>'string',
);
$columns[] = array(
'name'=>'PurchaseTime',
'dataType'=>'DateTime',
);
$table = array(
'name'=>$tablename,
'columns'=> $columns,
);
$data = array(
'name'=>'Client',
'tables'=>array($table),
);
$url ="https://api.PowerBI.com/v1.0/myorg/datasets";
$header[] ="Authorization:$token_type $token";
$header[] ="Content-Type: application/json";
$header[]= "content_length:0";
$data1 = utf8_encode(json_encode($data));
$res = $this->get_respond('creat',$data1,$header,$url);
return $res;I find error my cloumn setting woring
HTTP/1.1 403 Forbidden Content-Length: 0 Server: Microsoft-HTTPAPI/2.0 Strict-Transport-Security: max-age=31536000; includeSubDomains X-Frame-Options: deny X-Content-Type-Options: nosniff RequestId: cbd09b84-064f-4257-b35d-9c9bb4a6d70a Date: Fri, 14 Oct 2016 06:15:04 GMT
server respond massage
session_start();
$access = $this->token();
$token_type = $access->token_type;
$token = $access->access_token;
date_default_timezone_set('UTC');
$date = date('D , d M Y H:i:s');
//Sun, 20 Sep 2009 20:36:40 GMT
$tablename = 'info';
$columns[] = array(
'name'=>'Number',
'dataType'=>'Int64',
);
$columns[] = array(
'name'=>'ClinetId',
'dataType'=>'Int64',
);
$columns[] = array(
'name'=>'Price',
'dataType'=>'Int64',
);
$columns[] = array(
'name'=>'MenuId',
'dataType'=>'string',
);
$columns[] = array(
'name'=>'PurchaseTime',
'dataType'=>'DateTime',
);
$table = array(
'name'=>$tablename,
'columns'=> $columns,
);
$data = array(
'name'=>'Client',
'tables'=>array($table),
);
$url ="https://api.PowerBI.com/v1.0/myorg/datasets";
$header[] ="Authorization:$token_type $token";
$header[] ="Content-Type: application/json";
$header[]= "content_length:0";
$data1 = utf8_encode(json_encode($data));
$res = $this->get_respond('creat',$data1,$header,$url);
return $res;I find error my cloumn setting woring
thank you eric_zhang i have been slove
it is my json code
{"name":"Client","table":{"name":"1467e0ce-1452-4f96-b830-ade8dcb47c38","columns":[{"name":"PorductID","type":"Text"},{"name":"Name","type":"Text"},{"name":"Number","type":"Number"},{"name":"Price","type":"Number"},{"name":"MenuId","type":"Text"},{"name":"PurchaseTime","type":"DateTime"},{"name":"SPN","type":"Text"}]}}
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 |