Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
FelixC
New Member

Upload a JSON file using Power BI API

Hi,

I'm trying to upload a small json file to create a new dataset using the import API with Postman but I always get 400 Bad Request (RequestedFileIsEncryptedOrCorrupted) as response.

Here is the response

 

{
    "error": {
        "code": "RequestedFileIsEncryptedOrCorrupted",
        "pbi.error": {
            "code": "RequestedFileIsEncryptedOrCorrupted",
            "parameters": {},
            "details": [],
            "exceptionCulprit": 1
        }
    }
}

 

 

The content of my json

 

[
	{
		"id": 1,
		"name": "Luke",
		"randomNumber" : 5.854668
	},
	{
		"id": 2,
		"name": "Lisa",
		"randomNumber" : 10.3846846
	},
	{
		"id": 3,
		"name": "Tom",
		"randomNumber" : 52.36541
	}
]

 

 

Postman snapshots

FelixC_0-1635325268146.png

FelixC_1-1635325284720.png

 

I also tried with others .json and .xlsx but I get the same error and I don't know why, maybe I missed something in the doc.

Thanks for help!

10 REPLIES 10
Greg_Deckler
Super User
Super User

@FelixC I thought json files were only for importing dataflows.

Imports - Post Import - REST API (Power BI Power BI REST APIs) | Microsoft Docs

Is this being set? Hard to see in your screen shots:

  • To import a file, specify the content type multipart/form-data in the request headers and encode the file as form data in the request body.

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler 
Yes, Content-Type is set to "multipart/form-data", you can click on screenshot to open image.

I'm new with PowerBi and this API so maybe it's not the good way to create dataset.
I just want to create new dataset in Power BI online service from a web server with json or directly from my database. This has to be automatic so I can't use Power BI Desktop.


@FelixC Here's what I would try. Create a small, couple MB PBIX file and see if you can post it as a dataset using the API. This should remove any doubt about whether it is something you are doing wrong in postman or it is simply that you are trying to do something that is not supported with a JSON file. I can't find any information about using JSON to create datasets other than maybe Push datasets. This article claims to do what you want to do but doesn't actually use the Power BI REST API, I think the author is confused.

Importing data from JSON files and Power BI Rest APIs into Power BI (sqlshack.com)



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler
I just tried and it works with a PBIX file so maybe it's not possible with json. 
I read this article but the author use an external api to generate data and connect PowerBI desktop on it and that's not what I want.

It's really strange there is no way to add new data from json or database to PowerBI online like in PowerBI desktop.
Maybe I sould create a new ticket for this question.

Hi @FelixC 

I think you can try Post Import or Post Import in Group Rest API to import Json File in your My Workspace or App Workspaces.

1.png

For reference:

Imports - Post Import

Imports - Post Import In Group

To use this Rest API, you need Dataset.ReadWrite.All permission. You can select it in API Permission in Azure portal.

You can use "Try it" to have a test from Link. If you configure your APP correctly, you should succeed.

I suggest you to check your Authorization Bear token. I can get access token by API in Postman then copy this bear token into Authorization pane instead of adding it in Header pane.

For reference: Power BI REST API using postman - generate embed token.

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi,
how in the "Try it" I can upload my json file?

Thanks for your help

Hi @FelixC 

According to the blog, Power BI supports us to create a dataflow from a model.json file.

  • To import a file, specify the content type multipart/form-data in the request headers and encode the file as form data in the request body.
  • To create a dataflow from a model.json file, set datasetDisplayName to model.json, as described in URI parameters.

We can use dataflow as the datasource to create a dataset.

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Yes, but here

FelixC_0-1635844763827.png

I can't add my file and I don't know how to encode the file as form data in this form.
In postman there is a section for "form data" file and it works for pbix file but not for json.

Félix

Hi @FelixC 

I find a post with similar requirement like yours. I hope it could help you.

For reference: Power BI API Dataflow Import Operation

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-rzhou-msft,
Thanks for the link, I'll give it a try.
So after multiple research it is not possible to add data in dataset from a json. This API route is used to create dataflow!

Best Regards
Félix

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.