Forum Discussion
vaalyushin
4 years agoHelper I
Upload pbix with python
Hi! I have Power BI Report Server May 2022 and i try to upload pbix-file use api. I write this code: from asyncio.windows_events import NULL
from requests import request
import requests
fro...
d_gosbell
4 years agoSuper User
I'm pretty sure you need to use the CatalogItems endpoint to upload reports.
eg.
from asyncio.windows_events import NULL
from requests import request
import requests
import base64
import json
from requests_negotiate_sspi import HttpNegotiateAuth
from urllib3.exceptions import InsecureRequestWarning
from urllib3 import disable_warnings
disable_warnings(InsecureRequestWarning)
urlpbirs = "http://localhost/reports/api/v2.0/CatalogItems"
file = "C:/temp/test.pbix"
file_text = open(file, 'rb')
file_read = file_text.read()
file_encode = base64.b64encode(file_read).decode('utf-8')
headers = {
'accept': 'application/json',
'Content-Type': 'application/json',
}
json_data = {
'Name': 'BI Test 2',
'@odata.type': '#Model.PowerBIReport',
'ContentType': '',
'Content': file_encode,
'Path': '/BI Test 2'
}
r = requests.post(url=urlpbirs, auth=HttpNegotiateAuth(), verify=False, headers=headers, json=json_data)
print(r)- Cylogus3 years agoRegular Visitor
This code works well?