Forum Discussion
API Import 400 Bad Request Error when uploading pbix file
- 9 years ago
For new reports just remove the name conflict parameter
When I try to upload a file that previously exists using the URL with ?datasetDisplayName={2}&nameConflict=Overwrite at the end, it works great. However when the report is a new report, and I try to upload it using...
https://api.powerbi.com/v1.0/myorg/groups/{GroupID}/imports
It does not update. In the code that you gave me to catch the error, all I see is the word Message: "". It does not tell me anything more. Previously you said that if you try to import a report, that does not exist, and use the ?datasetDisplayName={2}&nameConflict=Overwrite at end of URL, that it will not work. Well it seems even without that it does not work. Any thoughts why?
Thanks,
Stizz001
For new reports just remove the name conflict parameter
- Anonymous9 years agoNot applicableYea, i ended up figuring that out late today. Sorry for not updating the thread. I appreciate all your help. I wpuld have struggled a lot more than I did without it.
- ddavid8 years agoNew Member
Hi Anonymous ,
I am getting <Response [400]>, when I run this code. Any idea what is wrong ?
Thanks in advance.
import requests
values = """
-----BOUNDARY
Content-Disposition: form-data; name="mypbix"; filename="mypbix.pbix"
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64
{PBIX binary data}
-----BOUNDARY"""
headers = {
'Content-Type': 'multipart/form-data; boundary=---BOUNDARY',
'Authorization': 'Bearer <access_token>'
}
request = requests.post('https://api.powerbi.com/v1.0/myorg/groups/<group_id>/imports?datasetDisplayName=ProductOrder', data=values, headers=headers)