Unable to Upload the RDL to PowerBI portal via POST method

Rajesh 21 Reputation points

Hello Team,

We are unable to upload a paginated report that has simple custom code to the PowerBI portal using the POST Method (Powershell script).


The below is the compilation error we are getting while trying to upload the rdl file.

           **Report is invalid. ErrorCode: rsUnexpectedCompilerError, Details: An unexpected error occurred while compiling expressions. Native compiler return value: [BC42105] Function TestFun doesnt return a value on all code paths. A null reference exception could occur at run time when the result is used..**

To reproduce the issue we have tried with simple report that has below custom code.

Custom Code:
Public Function TestFun() As String
Return "hi"
End Function

We are using the below url to post the rdl file.


Is there any way to skip the compilation error and continue the upload ?


SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
9,860 questions
SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,367 questions
0 comments No comments
{count} votes

Accepted answer
  1. Joyzhao-MSFT 15,471 Reputation points Microsoft Employee

    Hi @Rajesh ,
    This is a pretty standard/vague error. You might try checking the Reports error log.
    Native mode report server
    APPLIES TO: ✔️ SQL Server Reporting Services (2016)
    C:\Program Files\Microsoft SQL Server\MSRS13.MSSQLSERVER\Reporting Services\ReportServer

    APPLIES TO: ✔️ SQL Server Reporting Services (2017 and later)
    C:\Program Files\Microsoft SQL Server Reporting Services\SSRS\ReportServer

    APPLIES TO: ✔️ Power BI Report Server
    C:\Program Files\Microsoft Power BI Report Server\PBIRS\ReportServer

    For PowerBI related issues, we recommend that you initiate an inquiry on the relevant forum: Microsoft Power BI Community.
    Best Regards,

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Rajesh 21 Reputation points

    Thanks for the reply.

    Based on the Sample Function it actually returned all path still we are getting the same issue.

    Just checking if we have to make any changes in RDL function so that we can upload it without errors via POST method.


    0 comments No comments