microsoft / PowerBI-Node

Node SDK and client library for Power BI REST APIs.
https://dev.powerbi.com
Other
79 stars 31 forks source link

Post Import expects filePath as string #14

Closed ekeijl closed 7 years ago

ekeijl commented 8 years ago

I'm trying to upload a pbix file using the imports.postImport function, but it results in an HTTP 400 response.

It expects importInfo containing the filePath as the 4th parameter. The filePath is sent on the request body, while it should be sending contents of the pbix file, as in the API docs example.

If I try to send the file data, I get the following error: Error "importInfo.filePath with value '[object Object]' must be of type string." occurred in serializing the payload

I did succeed in uploading a pbix file by making a call to the Post Import API directly using a ReadStream to send the contents of the file.

wbreza commented 8 years ago

Ensure you are passing a dataset displayname. Take a look at the Power BI Node CLI for an example or using the import API.

client.imports.uploadFile(settings.collection, settings.workspace, settings.file, options, callback);

ekeijl commented 8 years ago

Thank you, that is exactly what I was looking for. It is not very clear that I had to use the uploadFile method, some documentation might be helpful. This issue can be closed, I guess.

So, what is the use case for the postImport method?

wbreza commented 8 years ago

@ekeijl - I agree this is confusing. The bulk of this API is auto-generated from an Azure tool called AutoRest which takes a Swagger definition and generates a client API. Its great for most use cases except for this import case when direct manipulation of the HTTP request is required.

We extended the import with the custom uploadFile method to make this more straight forward.

We'll take a closer look and see how we can clean this up in a future release.