Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Create a report from an existing one with PBIRS API

Hi everybody

 

I am trying to create a new report in PBIRS using only APIs.

I've been able to breate the report but I've no idea how to put the content of the report in the API BODY.

 

I've got the content of an existing report using the /PowerBIReports({Id})/Content/$value. I obtain a binary content that I think is simply the .pbix file, but if I try to put the same exact content in the POST /PowerBIReports I obtain errors on the json

 

"message": "Invalid JSON. A comma character ',' was expected in scope 'Object'. Every two elements in an array and properties of an object must be separated by commas."

 
Which is the expected format of the content field?
 
Thanks!
 
 

4 Replies

  • I'm pretty sure you would need to base64 encode this content in order to include it in the json body

    • Anonymous's avatar
      Anonymous
      Not applicable

      Yes, that's exactly what the POST body documentation of the content parameter says:

       

      string

      A string value that contains binary encoding by base64url encoding rules. The value of this property is not processed by the server. In object creation the server receives and stores a value, and in object retrieval the server returns the previously stored value.

       

      For this reason I simply base64 encoded the content of a pbix file but without success. 

      • d_gosbell's avatar
        d_gosbell
        Icon for Super User rankSuper User

        Anonymous wrote:

        For this reason I simply base64 encoded the content of a pbix file but without success. 


        This is not what you said in your initial post where you get the response from /PowerBIReports({Id})/Content/$value. You said:

         


        Anonymous wrote:

        if I try to put the same exact content in the POST /PowerBIReports I obtain errors on the json


        So are you actually doing the base64 encoding yourself? Because I do not believe the return value from /PowerBIReports({Id})/Content/$value is base64 encoded, it appears to be raw binary.

        If you are doing the base64 encoding yourself then you must be missing a comma somewhere else in the post body as the error message says.