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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
BryanCarmichael
Helper II
Helper II

Error on create report

Hi 

I have extracted a repor definition for an existing simple report and stored it in a lakehouse table by part both encoded and decoded

However when I try and use this to recreate the report in a different workspace I get the following error:

'status': 'Failed', 'createdTimeUtc': '2025-03-03T14:44:01.5991557', 'lastUpdatedTimeUtc': '2025-03-03T14:44:02.0210561', 'percentComplete': None, 'error': {'errorCode': 'Workload_FailedToParseFile', 'message': "Cannot read 'report.json'. After parsing a value an unexpected character was encountered: v. Path 'config', line 1, position 17."}

 

If i pass the extracted encoded string it works perfectly  - not sure what is going wrong 

 

Code is below with sensitive details replacd with XXXXXXX  - any help greatly appreciated 

 

import requests
import json
import time
import base64

workspaceID = "XXXXXXX"
reportName = "Test client publish 2"
reportDescription = "this should be filtered to 1211"
clientGroupCode = "1211"
#Should not need to change definition block
definitionElementName = 'definition.pbir'
definitionJson = '''{ "version": "4.0", "datasetReference": { "byConnection": { "connectionString": "Data Source=XXXXXXX;Initial Catalog=XXXXXXX;Integrated Security=ClaimsToken", "pbiServiceModelId": null, "pbiModelVirtualServerName": "sobe_wowvirtualserver", "pbiModelDatabaseName": "c2049598-3bae-4081-8941-32d80d4a6bca", "name": "EntityDataSource", "connectionType": "pbiServiceXmlaStyleLive" } }}'''
#Will need replacing each republish
themeElementName = 'StaticResources/SharedResources/BaseThemes/CY24SU10.json'
themeJson ='''{  "name": "CY24SU10",  "dataColors": [  "#118DFF",  "#12239E",  "#E66C37",  "#6B007B",  "#E044A7",  "#744EC2",  "#D9B300",  "#D64550",  "#197278",  "#1AAB40",  "#15C6F4",  "#4092FF",  "#FFA058",  "#BE5DC9",  "#F472D0",  "#B5A1FF",  "#C4A200",  "#FF8080",  "#00DBBC",  "#5BD667",  "#0091D5",  "#4668C5",  "#FF6300",  "#99008A",  "#EC008C",  "#533285",  "#99700A",  "#FF4141",  "#1F9A85",  "#25891C",  "#0057A2",  "#002050",  "#C94F0F",  "#450F54",  "#B60064",  "#34124F",  "#6A5A29",  "#1AAB40",  "#BA141A",  "#0C3D37",  "#0B511F"  ],  "foreground": "#252423",  "foregroundNeutralSecondary": "#605E5C",  "foregroundNeutralTertiary": "#B3B0AD",  "background": "#FFFFFF",  "backgroundLight": "#F3F2F1",  "backgroundNeutral": "#C8C6C4",  "tableAccent": "#118DFF",  "good": "#1AAB40",  "neutral": "#D9B300",  "bad": "#D64554",  "maximum": "#118DFF",  "center": "#D9B300",  "minimum": "#DEEFFF",  "null": "#FF7F48",  "hyperlink": "#0078d4",  "visitedHyperlink": "#0078d4",  "textClasses": {  "callout": {  "fontSize": 45,  "fontFace": "DIN",  "color": "#252423"  },  "title": {  "fontSize": 12,  "fontFace": "DIN",  "color": "#252423"  },  "header": {  "fontSize": 12,  "fontFace": "Segoe UI Semibold",  "color": "#252423"  },  "label": {  "fontSize": 10,  "fontFace": "Segoe UI",  "color": "#252423"  }  },  "visualStyles": {  "*": {  "*": {  "*": [  {  "wordWrap": true  }  ],  "line": [  {  "transparency": 0  }  ],  "outline": [  {  "transparency": 0  }  ],  "plotArea": [  {  "transparency": 0  }  ],  "categoryAxis": [  {  "showAxisTitle": true,  "gridlineStyle": "dotted",  "concatenateLabels": false  }  ],  "valueAxis": [  {  "showAxisTitle": true,  "gridlineStyle": "dotted"  }  ],  "y2Axis": [  {  "show": true  }  ],  "title": [  {  "titleWrap": true  }  ],  "lineStyles": [  {  "strokeWidth": 3  }  ],  "wordWrap": [  {  "show": true  }  ],  "background": [  {  "show": true,  "transparency": 0  }  ],  "border": [  {  "width": 1  }  ],  "outspacePane": [  {  "backgroundColor": {  "solid": {  "color": "#ffffff"  }  },  "transparency": 0,  "border": true,  "borderColor": {  "solid": {  "color": "#B3B0AD"  }  }  }  ],  "filterCard": [  {  "$id": "Applied",  "transparency": 0,  "foregroundColor": {  "solid": {  "color": "#252423"  }  },  "border": true  },  {  "$id": "Available",  "transparency": 0,  "foregroundColor": {  "solid": {  "color": "#252423"  }  },  "border": true  }  ]  }  },  "scatterChart": {  "*": {  "bubbles": [  {  "bubbleSize": -10,  "markerRangeType": "auto"  }  ],  "general": [  {  "responsive": true  }  ],  "fillPoint": [  {  "show": true  }  ],  "legend": [  {  "showGradientLegend": true  }  ]  }  },  "lineChart": {  "*": {  "general": [  {  "responsive": true  }  ],  "smallMultiplesLayout": [  {  "backgroundTransparency": 0,  "gridLineType": "inner"  }  ],  "forecast": [  {  "matchSeriesInterpolation": true  }  ]  }  },  "map": {  "*": {  "bubbles": [  {  "bubbleSize": -10,  "markerRangeType": "auto"  }  ]  }  },  "azureMap": {  "*": {  "bubbleLayer": [  {  "bubbleRadius": 8,  "minBubbleRadius": 8,  "maxRadius": 40  }  ],  "barChart": [  {  "barHeight": 3,  "thickness": 3  }  ]  }  },  "pieChart": {  "*": {  "legend": [  {  "show": true,  "position": "RightCenter"  }  ],  "labels": [  {  "labelStyle": "Data value, percent of total"  }  ]  }  },  "donutChart": {  "*": {  "legend": [  {  "show": true,  "position": "RightCenter"  }  ],  "labels": [  {  "labelStyle": "Data value, percent of total"  }  ]  }  },  "pivotTable": {  "*": {  "rowHeaders": [  {  "showExpandCollapseButtons": true,  "legacyStyleDisabled": true  }  ]  }  },  "multiRowCard": {  "*": {  "card": [  {  "outlineWeight": 2,  "barShow": true,  "barWeight": 2  }  ]  }  },  "kpi": {  "*": {  "trendline": [  {  "transparency": 20  }  ]  }  },  "cardVisual": {  "*": {  "layout": [  {  "maxTiles": 3  }  ],  "overflow": [  {  "type": 0  }  ],  "image": [  {  "fixedSize": false  },  {  "imageAreaSize": 50  }  ]  }  },  "advancedSlicerVisual": {  "*": {  "layout": [  {  "maxTiles": 3  }  ]  }  },  "slicer": {  "*": {  "general": [  {  "responsive": true  }  ],  "date": [  {  "hideDatePickerButton": false  }  ],  "items": [  {  "padding": 4,  "accessibilityContrastProperties": true  }  ]  }  },  "waterfallChart": {  "*": {  "general": [  {  "responsive": true  }  ]  }  },  "columnChart": {  "*": {  "general": [  {  "responsive": true  }  ],  "legend": [  {  "showGradientLegend": true  }  ],  "smallMultiplesLayout": [  {  "backgroundTransparency": 0,  "gridLineType": "inner"  }  ]  }  },  "clusteredColumnChart": {  "*": {  "general": [  {  "responsive": true  }  ],  "legend": [  {  "showGradientLegend": true  }  ],  "smallMultiplesLayout": [  {  "backgroundTransparency": 0,  "gridLineType": "inner"  }  ]  }  },  "hundredPercentStackedColumnChart": {  "*": {  "general": [  {  "responsive": true  }  ],  "legend": [  {  "showGradientLegend": true  }  ],  "smallMultiplesLayout": [  {  "backgroundTransparency": 0,  "gridLineType": "inner"  }  ]  }  },  "barChart": {  "*": {  "general": [  {  "responsive": true  }  ],  "legend": [  {  "showGradientLegend": true  }  ],  "smallMultiplesLayout": [  {  "backgroundTransparency": 0,  "gridLineType": "inner"  }  ]  }  },  "clusteredBarChart": {  "*": {  "general": [  {  "responsive": true  }  ],  "legend": [  {  "showGradientLegend": true  }  ],  "smallMultiplesLayout": [  {  "backgroundTransparency": 0,  "gridLineType": "inner"  }  ]  }  },  "hundredPercentStackedBarChart": {  "*": {  "general": [  {  "responsive": true  }  ],  "legend": [  {  "showGradientLegend": true  }  ],  "smallMultiplesLayout": [  {  "backgroundTransparency": 0,  "gridLineType": "inner"  }  ]  }  },  "areaChart": {  "*": {  "general": [  {  "responsive": true  }  ],  "smallMultiplesLayout": [  {  "backgroundTransparency": 0,  "gridLineType": "inner"  }  ]  }  },  "stackedAreaChart": {  "*": {  "general": [  {  "responsive": true  }  ],  "smallMultiplesLayout": [  {  "backgroundTransparency": 0,  "gridLineType": "inner"  }  ]  }  },  "lineClusteredColumnComboChart": {  "*": {  "general": [  {  "responsive": true  }  ],  "smallMultiplesLayout": [  {  "backgroundTransparency": 0,  "gridLineType": "inner"  }  ]  }  },  "lineStackedColumnComboChart": {  "*": {  "general": [  {  "responsive": true  }  ],  "smallMultiplesLayout": [  {  "backgroundTransparency": 0,  "gridLineType": "inner"  }  ]  }  },  "ribbonChart": {  "*": {  "general": [  {  "responsive": true  }  ],  "smallMultiplesLayout": [  {  "backgroundTransparency": 0,  "gridLineType": "inner"  }  ],  "valueAxis": [  {  "show": true  }  ]  }  },  "hundredPercentStackedAreaChart": {  "*": {  "general": [  {  "responsive": true  }  ],  "smallMultiplesLayout": [  {  "backgroundTransparency": 0,  "gridLineType": "inner"  }  ]  }  },  "group": {  "*": {  "background": [  {  "show": false  }  ]  }  },  "basicShape": {  "*": {  "background": [  {  "show": false  }  ],  "general": [  {  "keepLayerOrder": true  }  ],  "visualHeader": [  {  "show": false  }  ]  }  },  "shape": {  "*": {  "background": [  {  "show": false  }  ],  "general": [  {  "keepLayerOrder": true  }  ],  "visualHeader": [  {  "show": false  }  ]  }  },  "image": {  "*": {  "background": [  {  "show": false  }  ],  "general": [  {  "keepLayerOrder": true  }  ],  "visualHeader": [  {  "show": false  }  ],  "lockAspect": [  {  "show": true  }  ]  }  },  "actionButton": {  "*": {  "background": [  {  "show": false  }  ],  "visualHeader": [  {  "show": false  }  ]  }  },  "pageNavigator": {  "*": {  "background": [  {  "show": false  }  ],  "visualHeader": [  {  "show": false  }  ]  }  },  "bookmarkNavigator": {  "*": {  "background": [  {  "show": false  }  ],  "visualHeader": [  {  "show": false  }  ]  }  },  "textbox": {  "*": {  "general": [  {  "keepLayerOrder": true  }  ],  "visualHeader": [  {  "show": false  }  ]  }  },  "page": {  "*": {  "outspace": [  {  "color": {  "solid": {  "color": "#FFFFFF"  }  }  }  ],  "background": [  {  "transparency": 100  }  ]  }  }  } }'''
#Will need replacing each republish - also replace the groupcode specified as a every page filter with ~@CLIENTGROUPCODE@~
reportElementName = 'report.json'
reportJson = '''{  "config": "{ "version ": "5.59 ", "themeCollection ":{ "baseTheme ":{ "name ": "CY24SU10 ", "version ": "5.61 ", "type ":2}}, "activeSectionIndex ":0, "defaultDrillFilterOtherVisuals ":true, "settings ":{ "useNewFilterPaneExperience ":true, "allowChangeFilterTypes ":true, "useStylableVisualContainerHeader ":true, "queryLimitOption ":6, "exportDataMode ":1, "useDefaultAggregateDisplayName ":true, "useEnhancedTooltips ":true}, "objects ":{ "section ":[{ "properties ":{ "verticalAlignment ":{ "expr ":{ "Literal ":{ "Value ": "'Top' "}}}}}], "outspacePane ":[{ "properties ":{ "expanded ":{ "expr ":{ "Literal ":{ "Value ": "true "}}}}}]}}",  "filters": "[{ "name ": "2c6ae056070ab2a6c625 ", "expression ":{ "Column ":{ "Expression ":{ "SourceRef ":{ "Entity ": "_Protocol Hierarchy "}}, "Property ": "Client Group Code "}}, "filter ":{ "Version ":2, "From ":[{ "Name ": "_ ", "Entity ": "_Protocol Hierarchy ", "Type ":0}], "Where ":[{ "Condition ":{ "Comparison ":{ "ComparisonKind ":0, "Left ":{ "Column ":{ "Expression ":{ "SourceRef ":{ "Source ": "_ "}}, "Property ": "Client Group Code "}}, "Right ":{ "Literal ":{ "Value ": "200L "}}}}}]}, "type ": "Advanced ", "howCreated ":1}]",  "layoutOptimization": 0,  "resourcePackages": [  {  "resourcePackage": {  "disabled": false,  "items": [  {  "name": "CY24SU10",  "path": "BaseThemes/CY24SU10.json",  "type": 202  }  ],  "name": "SharedResources",  "type": 2  }  }  ],  "sections": [  {  "config": "{}",  "displayName": "Distribution Summary",  "displayOption": 1,  "filters": "[]",  "height": 720.00,  "name": "55ce982c2d156837951c",  "ordinal": 1,  "visualContainers": [  {  "config": "{ "name ": "52adf0c83b93c68292a3 ", "layouts ":[{ "id ":0, "position ":{ "x ":9.888412017167383, "y ":0, "z ":0, "width ":1067.9484978540772, "height ":650.4377682403433, "tabOrder ":0}}], "singleVisual ":{ "visualType ": "lineChart ", "projections ":{ "Category ":[{ "queryRef ": "Operations - Distribution - Orders.Shipped Date.Variation.Date Hierarchy.Month ", "active ":true}], "Y ":[{ "queryRef ": "Sum(Operations - Distribution - Orders.Volume) "}], "Series ":[{ "queryRef ": "Operations - Distribution - Orders.Shipped Date.Variation.Date Hierarchy.Year "}]}, "prototypeQuery ":{ "Version ":2, "From ":[{ "Name ": "o ", "Entity ": "Operations - Distribution - Orders ", "Type ":0}], "Select ":[{ "HierarchyLevel ":{ "Expression ":{ "Hierarchy ":{ "Expression ":{ "PropertyVariationSource ":{ "Expression ":{ "SourceRef ":{ "Source ": "o "}}, "Name ": "Variation ", "Property ": "Shipped Date "}}, "Hierarchy ": "Date Hierarchy "}}, "Level ": "Month "}, "Name ": "Operations - Distribution - Orders.Shipped Date.Variation.Date Hierarchy.Month ", "NativeReferenceName ": "Shipped Date Month "},{ "Aggregation ":{ "Expression ":{ "Column ":{ "Expression ":{ "SourceRef ":{ "Source ": "o "}}, "Property ": "Volume "}}, "Function ":0}, "Name ": "Sum(Operations - Distribution - Orders.Volume) ", "NativeReferenceName ": "Sum of Volume "},{ "HierarchyLevel ":{ "Expression ":{ "Hierarchy ":{ "Expression ":{ "PropertyVariationSource ":{ "Expression ":{ "SourceRef ":{ "Source ": "o "}}, "Name ": "Variation ", "Property ": "Shipped Date "}}, "Hierarchy ": "Date Hierarchy "}}, "Level ": "Year "}, "Name ": "Operations - Distribution - Orders.Shipped Date.Variation.Date Hierarchy.Year ", "NativeReferenceName ": "Shipped Date Year "}]}, "drillFilterOtherVisuals ":true}}",  "filters": "[{ "expression ":{ "HierarchyLevel ":{ "Expression ":{ "Hierarchy ":{ "Expression ":{ "PropertyVariationSource ":{ "Expression ":{ "SourceRef ":{ "Entity ": "Operations - Distribution - Orders "}}, "Name ": "Variation ", "Property ": "Shipped Date "}}, "Hierarchy ": "Date Hierarchy "}}, "Level ": "Year "}}, "filter ":{ "Version ":2, "From ":[{ "Name ": "o ", "Entity ": "Operations - Distribution - Orders ", "Type ":0}], "Where ":[{ "Condition ":{ "Comparison ":{ "ComparisonKind ":2, "Left ":{ "HierarchyLevel ":{ "Expression ":{ "Hierarchy ":{ "Expression ":{ "PropertyVariationSource ":{ "Expression ":{ "SourceRef ":{ "Source ": "o "}}, "Name ": "Variation ", "Property ": "Shipped Date "}}, "Hierarchy ": "Date Hierarchy "}}, "Level ": "Year "}}, "Right ":{ "Literal ":{ "Value ": "2019L "}}}}}]}, "type ": "Advanced ", "howCreated ":0, "isHiddenInViewMode ":false}]",  "height": 650.44,  "width": 1067.95,  "x": 9.89,  "y": 0.00,  "z": 0.00  }  ],  "width": 1280.00  },  {  "config": "{}",  "displayName": "Org Structure",  "displayOption": 1,  "filters": "[]",  "height": 720.00,  "name": "ddf2c4cfa574fb65c4be",  "visualContainers": [  {  "config": "{ "name ": "5b4719a273a3cef6ed7b ", "layouts ":[{ "id ":0, "position ":{ "x ":12.085836909871245, "y ":35.1587982832618, "z ":0, "width ":581.2188841201717, "height ":672.4120171673819, "tabOrder ":0}}], "singleVisual ":{ "visualType ": "tableEx ", "projections ":{ "Values ":[{ "queryRef ": "_Protocol Hierarchy.Client "},{ "queryRef ": "_Protocol Hierarchy.Client Category "},{ "queryRef ": "_Protocol Hierarchy.Subsidiary "}]}, "prototypeQuery ":{ "Version ":2, "From ":[{ "Name ": "_ ", "Entity ": "_Protocol Hierarchy ", "Type ":0}], "Select ":[{ "Column ":{ "Expression ":{ "SourceRef ":{ "Source ": "_ "}}, "Property ": "Client "}, "Name ": "_Protocol Hierarchy.Client ", "NativeReferenceName ": "Client "},{ "Column ":{ "Expression ":{ "SourceRef ":{ "Source ": "_ "}}, "Property ": "Client Category "}, "Name ": "_Protocol Hierarchy.Client Category ", "NativeReferenceName ": "Client Category "},{ "Column ":{ "Expression ":{ "SourceRef ":{ "Source ": "_ "}}, "Property ": "Subsidiary "}, "Name ": "_Protocol Hierarchy.Subsidiary ", "NativeReferenceName ": "Subsidiary "}]}, "drillFilterOtherVisuals ":true}}",  "filters": "[]",  "height": 672.41,  "width": 581.22,  "x": 12.09,  "y": 35.16,  "z": 0.00  }  ],  "width": 1280.00  }  ] }'''
#Should not need to change platform block
platformElementName = '.platform'

#authenticate
platformJson = '''{  "$schema": "https://developer.microsoft.com/json-schemas/fabric/gitIntegration/platformProperties/2.0.0/schema.j...",  "metadata": {  "type": "Report",  "displayName": "az"  },  "config": {  "version": "2.0",  "logicalId": "00000000-0000-0000-0000-000000000000"  } }'''
token_string = mssparkutils.credentials.getToken("https://api.fabric.microsoft.com/")
header = {'Content-Type':'application/json','Authorization': f'Bearer {token_string}'}
#Build body
addbody = {
  "displayName": reportName,
  "description": reportDescription,
  "definition": {
    "parts": [
      {
        "path": definitionElementName,
        "payload": base64.b64encode(definitionJson.encode('utf-8')),
        "payloadType": "InlineBase64"
      },
      {
        "path": themeElementName,
        "payload": base64.b64encode(themeJson.encode('utf-8')),
        "payloadType": "InlineBase64"
      },
      {
        "path": reportElementName,
        "payload": base64.b64encode(reportJson.encode('utf-8')),
        "payloadType": "InlineBase64"
      },
      {
        "path": platformElementName,
        "payload": base64.b64encode(platformJson.encode('utf-8')),
        "payloadType": "InlineBase64"
      }
    ]
  }
}


addURL = 'https://api.fabric.microsoft.com/v1/workspaces/' + workspaceID + '/reports'
add_Response = requests.post(addURL, headers=header, json=addbody)
print(add_Response)
if add_Response.status_code == 202 :
    print("waiting")
    finished = False
    checkBody ={}
    while not finished:
     check_Response = requests.get(add_Response.headers['Location'],headers=header, data=json.dumps(checkBody))
     checkData =check_Response.json()
     if checkData['status'] == "Succeeded":
        print("done")
        finished = True
        break
     elif  checkData['status'] == "Failed":  
        print("failed")
        print(checkData)
        finished = True
        break
     else :
        print(checkData['status'])

1 ACCEPTED SOLUTION

Hi - thanks for the response.

I did not manage to resolve this using the legacy pbip approach with just one report.json - consistently got the failure encoded or not despite checking the json was valid and sending it preencoded or not - I think there is some hidden nuance or possibly a defect in the API.

 

However on moving to using the new PBIP format it worked first time and worked consistently so my issue is now resolved.

View solution in original post

3 REPLIES 3
v-sgandrathi
Community Support
Community Support

Hi @BryanCarmichael,

Happy to see you here in the Microsoft Fabric Community!

Based on my knowledge, here are the troubleshooting steps that may resolve your issue:
Ensure your JSON keys are free of trailing or leading spaces (e.g., "version " should be "version"). Use a method to trim spaces from the keys before parsing the JSON.

Maintain consistent base64 encoding/decoding across systems to prevent data corruption. Any discrepancies in encoding can cause parsing issues when transferring report data.

Verify that all sections of the report (e.g., config, filters) are well-formed and contain valid data.

The problem could also be related to specific workspace or configuration settings that differ between environments. Ensure the workspace in which you're deploying the report has the same configurations and settings as the original workspace.

Simplify the reportJson to its minimum and attempt to generate the report again. This will help identify if specific sections are causing the parsing issue.


I hope my suggestions provided valuable insights. If you have any further questions, feel free to reach out to us.

If this post helped, please mark it as "Accept as Solution" so others can benefit as well.

Best regards,
Sahasra.

Hi - thanks for the response.

I did not manage to resolve this using the legacy pbip approach with just one report.json - consistently got the failure encoded or not despite checking the json was valid and sending it preencoded or not - I think there is some hidden nuance or possibly a defect in the API.

 

However on moving to using the new PBIP format it worked first time and worked consistently so my issue is now resolved.

Hi @BryanCarmichael,

 

I'm glad you found a solution and resloved  the query. Thank you very much for sharing here.

Kindly mark your reply as the accepted solution so that others in the community can find it quickly.

 

Thankyou for connecting with Microsoft Community Forum.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June FBC25 Carousel

Fabric Monthly Update - June 2025

Check out the June 2025 Fabric update to learn about new features.