admin管理员组文章数量:1122832
I'm getting started with Reporting Services now and trying to create an automation to upload reports to the SSRS server.
The problem is i'm getting this error when trying to use the POST method:
{
"error": {
"code": "",
"message": "Cannot create an abstract class."
}
}
That's how the body of my requisition is:
{
"Name":"MyReport",
"Type":"Report",
"ParentFolder": {
"Name": "Reports"
},
"Content":".rdl file bytes"
I'm trying to use it with c#, here's the code:
private async Task<string> PostReportAsync(string jsonPayload)
{
using (HttpClientHandler handler = new HttpClientHandler { UseDefaultCredentials = true })
using (HttpClient client = new HttpClient(handler))
{
client.DefaultRequestHeaders.Add("Accept", "application/json");
HttpContent content = new StringContent(jsonPayload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(_apiUrl, content);
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine($"Response: {responseBody}");
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStringAsync();
}
}
In addition to that, I have this method:
public async Task<string> UploadReportAsync(string reportName, string parentFolder, string reportFilePath)
{
try
{
byte[] fileBytes = await File.ReadAllBytesAsync(reportFilePath);
string base64Content = Convert.ToBase64String(fileBytes);
var payload = new
{
Name = reportName,
Type = "Report",
ParentFolder = parentFolder,
Content = base64Content
};
string jsonPayload = JsonSerializer.Serialize(payload);
return await PostReportAsync(jsonPayload);
}
catch (Exception ex)
{
throw new Exception("Erro ao fazer upload do relatório", ex);
}
}
Is there something wrong with the requisition body? I can't find anything on the API docs.
本文标签: cSQL Server Reporting Services API documentationStack Overflow
版权声明:本文标题:c# - SQL Server Reporting Services API documentation - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736307677a1933397.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论