Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreThe FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now
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'])
Solved! Go to Solution.
Hi @Anonymous,
Thanks for reaching out to the Microsoft fabric community forum.
It looks like that the issue lies in the incorrect JSON formatting within the "reportJson" string. Specifically, the keys and values inside the config and filters fields are not properly escaped, which is causing the parsing error. The reportJson string contains extra spaces after the keys This could be breaking the JSON parser. Also there can be
Encoding/Decoding Issues. If the JSON is stored in an encoded format (e.g., Base64), ensure it is properly decoded before use. If it is already in plain text, check for any double encoding or unintended escape characters.
If I misunderstand your needs or you still have problems on it, please feel free to let us know.
Best Regards,
Hammad.
Community Support Team
If this post helps then please mark it as a solution, so that other members find it more quickly.
Thank you.
Hi @Anonymous,
Thanks for reaching out to the Microsoft fabric community forum.
It looks like that the issue lies in the incorrect JSON formatting within the "reportJson" string. Specifically, the keys and values inside the config and filters fields are not properly escaped, which is causing the parsing error. The reportJson string contains extra spaces after the keys This could be breaking the JSON parser. Also there can be
Encoding/Decoding Issues. If the JSON is stored in an encoded format (e.g., Base64), ensure it is properly decoded before use. If it is already in plain text, check for any double encoding or unintended escape characters.
If I misunderstand your needs or you still have problems on it, please feel free to let us know.
Best Regards,
Hammad.
Community Support Team
If this post helps then please mark it as a solution, so that other members find it more quickly.
Thank you.
Hi @Anonymous,
As we haven’t heard back from you, so just following up to our previous message. I'd like to confirm if you've successfully resolved this issue or if you need further help.
If yes, you are welcome to share your workaround and mark it as a solution so that other users can benefit as well. If you find a reply particularly helpful to you, you can also mark it as a solution.
If you still have any questions or need more support, please feel free to let us know. We are more than happy to continue to help you.
Thank you for your patience and look forward to hearing from you.
Hi @Anonymous,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution so that other community members can find it easily.
Thank you.
Hi @Anonymous,
May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank you.
Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 15 | |
| 7 | |
| 6 | |
| 5 | |
| 4 |