report server api upload report

1 Answer 78 Views
General Discussions Migration Report Management Rest API
sean
Top achievements
Rank 1
sean asked on 07 Aug 2023, 07:50 PM | edited on 09 Aug 2023, 12:48 PM

what am i doing wrong,

trying  to post to the UploadReport model report /api/reportserver/v2/reports

 

@{ "ModelState"= @{
                "Name"="rpt1";
                "Description"="uploaded on $(Get-Date -DisplayHint Date)";
                "CategoryId"="$($catId)"; 
                "ReportFile"=@{ 
                    "Name"="rpt1"; 
                    "FileName"="c:\x\rpt1.trdp";
                    "MediaType"="application/x-zip-compressed";
                    "Buffer"="[System.IO.File]::ReadAllBytes( "c:\x\rpt1.trdp" ) )"  }

      }

}

{"Message":"The request is invalid.","ModelState":{"model.Name":["The Name field is required."],"model.CategoryId":["The CategoryId field is
     | required."],"model.ReportFile":["The ReportFile field is required."]}}
sean
Top achievements
Rank 1
commented on 08 Aug 2023, 06:18 PM

{
  "Name": "rpt",
  "Description": "uploaded on 08/08/2023",
  "CategoryId": "8fi46djt0jr",
  "ReportFile": {
    "Name": "rpt",
    "FileName": "rpt.trdp",
    "MediaType": "application/x-zip-compressed", "Buffer": "80 75 ++++" } }

 

Anyone still work these forums? this is driving me nuts

 

 {"Message":"The request is invalid.","ModelState":{"model.Name":["The Name field is required."],"model.CategoryId":["The CategoryId field is
     | required."],"model.ReportFile":["The ReportFile field is required."]}}

1 Answer, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 10 Aug 2023, 10:39 AM

Hi Sean,

If I understood correctly, you would like to create a new report on the Report Server with its REST API through the request POST api/reportserver/v2/reports.

Note that you may use the Report Server API Client we provide.

Can you specify how you make the requests? Consider sending us a sample code we may use to reproduce the issue and try to be more helpful.

Regards,
Todor
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

sean
Top achievements
Rank 1
commented on 10 Aug 2023, 01:19 PM | edited

 

Im trying to upload an existing report with the api with PowerShell. i can get/post to all the other endpoints.



           $headers = @{
               "Accept"="application/json"; 
               "Content-Type"="application/x-www-form-urlencoded"
               "Authorization"="bearer 4X8k++++" }

            $httpfile = @{
                Name="$rptName";
                FileName="$rptFileName";
                MediaType="application/x-zip-compressed";
                Buffer="$( Get-Content "$rptFullname" -AsByteStream )";
            } 

            $rptbody = [PSCustomObject]@{
                Name="$rptName";
                Description="$rptDesciption";
                CategoryId="$catagoryId"; 
                ReportFile = $httpfile
            } | ConvertTo-Json

            irm "$($base_uri)/api/reportserver/v2/reports" -Method POST -Headers $headers -Body $rptBody



{  #rptBody
  "Name": "rpt1",
  "Description": "uploaded on 08.Aug.23",
  "CategoryId": "04044ss3f4",
  "ReportFile": {
    "Name": "rpt1",
    "FileName": "rpt1.trdp",
    "MediaType": "application/x-zip-compressed",
    "Buffer": "80 75 3 4 2 ++++" } }

Thanks for assisting Todor, this is driving me nuts!

sean
Top achievements
Rank 1
commented on 10 Aug 2023, 01:25 PM

also we are using licensed installers Telerik_ReportServer_9_1_23_718_Dev 


Todor
Telerik team
commented on 14 Aug 2023, 08:04 AM

Hi Sean,

I already replied to the same question you asked in Support ticket #1619710.

Here is a link to a muted video on how I successfully uploaded a sample report utilizing your request, modified to refer to my local resources. Note that I made the requests with Postman.

I suspect that the problem is with the way the request is made from Powershell. You may use Fiddler to check the exact request made to the Report Server and check whether something is incorrectly encoded, etc.

Tags
General Discussions Migration Report Management Rest API
Asked by
sean
Top achievements
Rank 1
Answers by
Todor
Telerik team
Share this question
or