Forum Discussion

zaxbysdt's avatar
zaxbysdt
Regular Visitor
1 month ago
Solved

C# 5.1 API SDK missing error object from exports

It would appear that the Microsoft.PowerBI.Api 5.1.0 SDK for .NET has removed the Error object from the Export model.    Here's a raw response from Postman calling the https://api.powerbi.com/v1.0/...
  • v-moharafi-msft's avatar
    1 month ago

    Hi zaxbysdt 

    Thank you for sharing the detailed comparison.

    From what you've posted, it appears you're observing a discrepancy between the REST API response and the Microsoft.PowerBI.Api 5.1.0 .NET SDK.

    Your Postman response clearly includes an error object when the export status is Failed:

    "status": "Failed",

    "error": {

        "code": "...",

        "message": "...",

        "details": []

    }

    However, the Export model in Microsoft.PowerBI.Api 5.1.0 does not expose an Error property, which means the SDK cannot surface these failure details through its strongly typed model.

    Additionally, the current Microsoft Learn documentation for Get Export To File Status defines the Export object without an error property, even though the REST service appears to return one in failure scenarios. This suggests there is currently a mismatch between the service behavior, the SDK model, and the published documentation.

    As a workaround, you could:

    • Call the REST endpoint directly and inspect the raw JSON response.
    • Deserialize the response yourself instead of relying solely on the SDK model if you need the failure details.
    • If you're using the SDK, inspect the underlying HTTP response (if available) to capture the additional JSON payload.

    Based on the evidence you've provided, this looks like a potential SDK or documentation issue rather than expected behavior. 

    For Reference:
    Get Export To File Status (REST API)

    Best Regards,
    Abdul Rafi

  • Gautam_Kumar01's avatar
    1 month ago

    Hi zaxbysdt,

     

    Good catch - I can repro this on 5.1.0. The Export model is definitely missing the Error property even though the REST API returns it.

     

    **Workaround until fixed:**

    You can deserialize to a custom class or use `dynamic`/`JObject` to access the error:

     

    ```csharp

    var json = await response.Content.ReadAsStringAsync();

    var exportWithError = JsonSerializer.Deserialize<ExportWithError>(json);

     

    public class ExportWithError : Export 

    {

        public ExportError Error { get; set; }

    }

    public class ExportError 

    {

        public string Code { get; set; }

        public string Message { get; set; }

        public object[] Details { get; set; }

    }