0

我有一个可行的解决方案,它将使用 POST 请求将 rdl 报告定义部署到报告服务器。这些报告利用嵌入式 XML 数据源,其中包括目标端点的请求令牌(通过 https),因此不需要任何凭据。 随后,rdl 文件被定义为不需要凭据——这需要设置无人参与的执行帐户才能允许使用不使用凭据配置报告。这些报告的部署是成功的,但是,我遇到了一个初始问题和一个试图修复第一个问题的后续问题:

1) 部署时,SSRS Server 忽略了报表定义数据源凭据设置“无凭据登录数据源”,将数据源设置为提示输入凭据。

2) 作为#1 中描述的问题的解决方法,我尝试PUT针对端点发出额外的 API 请求 () /Reports(path='/folder/reportname')/DataSources,但是,我无法形成适当的 json 对象来完成请求。

编辑: 在仔细检查GET响应(包括下面稍微修改的示例)后,Id与嵌入式数据源相关联的Id'似乎也不起作用(我已经更新了之前包含的示例有效负载以省略 ID 并包含Name数据源的 ID,但这些请求仍然返回400 Bad Request状态代码。

编辑#2: 我对通过 Visual Studio (SSDT) 部署报告的熟悉让我忘记了凭据实际上并未定义为报告的一部分,这是不可取的,因为在许多情况下,凭据存储在源代码控制或报告服务器,他们可能会受到损害。这意味着我应该进行辅助 API 调用,但到目前为止,我还没有成功地制作一个对象以作为有效负载传递到该端点。

GET 请求响应示例/Reports(path='/folder/reportname')/DataSources

{
  "@odata.context": "https://my-report-server.com/reports/api/v2.0/$metadata#DataSources",
  "value": [
    {
      "Id": "00000747-020f-019c-e8be-4f8ff834bee5",
      "Name": "DebugSource",
      "Description": null,
      "Path": null,
      "Type": "DataSource",
      "Hidden": false,
      "Size": 0,
      "ModifiedBy": null,
      "ModifiedDate": "0001-01-01T00:00:00Z",
      "CreatedBy": null,
      "CreatedDate": "0001-01-01T00:00:00Z",
      "ParentFolderId": null,
      "ContentType": null,
      "Content": "",
      "IsFavorite": false,
      "Roles": [],
      "IsEnabled": true,
      "ConnectionString": "https://localhost:8082/some-api-endpoint",
      "DataSourceType": "XML",
      "IsOriginalConnectionStringExpressionBased": false,
      "IsConnectionStringOverridden": false,
      "CredentialRetrieval": "prompt",
      "CredentialsByUser": {
        "DisplayText": null,
        "UseAsWindowsCredentials": false
      },
      "CredentialsInServer": null,
      "IsReference": false
    },
    {
      "Id": "000009b9-0093-0257-52cc-e93a261f0862",
      "Name": "ActualAPIEndpointForNonDevUse",
      "Description": null,
      "Path": null,
      "Type": "DataSource",
      "Hidden": false,
      "Size": 0,
      "ModifiedBy": null,
      "ModifiedDate": "0001-01-01T00:00:00Z",
      "CreatedBy": null,
      "CreatedDate": "0001-01-01T00:00:00Z",
      "ParentFolderId": null,
      "ContentType": null,
      "Content": "",
      "IsFavorite": false,
      "Roles": [],
      "IsEnabled": true,
      "ConnectionString": null,
      "DataSourceType": "XML",
      "IsOriginalConnectionStringExpressionBased": true,
      "IsConnectionStringOverridden": false,
      "CredentialRetrieval": "prompt",
      "CredentialsByUser": {
        "DisplayText": null,
        "UseAsWindowsCredentials": false
      },
      "CredentialsInServer": null,
      "IsReference": false
    }
  ]
}

JSON 有效负载示例:1

(通过修改GET请求中的 json 摘录来创建/Reports(path='/folder/reportname')/DataSources

{
  "Name": "DebugSource",
  "Description": null,
  "Path": null,
  "Type": "DataSource",
  "Hidden": false,
  "Size": 0,
  "ModifiedBy": null,
  "ModifiedDate": "0001-01-01T00:00:00Z",
  "CreatedBy": null,
  "CreatedDate": "0001-01-01T00:00:00Z",
  "ParentFolderId": null,
  "ContentType": null,
  "Content": "",
  "IsFavorite": false,
  "Roles": [],
  "IsEnabled": true,
  "ConnectionString": "https://localhost/some-endpoint",
  "DataSourceType": "XML",
  "IsOriginalConnectionStringExpressionBased": false,
  "IsConnectionStringOverridden": false,
  "CredentialRetrieval": "none",
  "CredentialsByUser": {
    "DisplayText": null,
    "UseAsWindowsCredentials": false
  },
  "CredentialsInServer": null,
  "IsReference": false
}

JSON 有效负载示例:2(最小)

这将是理想的形式,并且应该基于 api 文档有效

{
  "Name": "DebugSource",
  "CredentialRetrieval": "none"
}

这里的理想解决方案是强制 SSRS 遵守嵌入式数据源设置的设置,但如果我能找出要使用的正确语法,额外的 REST API 调用也可以。

4

2 回答 2

1

您可以使用 Reports 门户获取所需的 json,它使用 api 与 SSRS 交换数据。

于 2020-11-20T23:03:35.153 回答
0

我忘了跟进这个问题:

我最终通过 Microsoft 支持解决了这个问题。达到这个端点:

http://reportserverurl/reports/api/v2.0/Reports(19489e3b-5653-466a-b242-43e4e198be49)/DataSources

使用这样的有效负载:

[{
"Name":"DataSourceUpdated",
"Description":null,
"Hidden":false,
"Path":"",
"IsEnabled":true,
"DataSourceSubType":null,
"DataModelDataSource":null,
"IsReference":false,
"DataSourceType":"SQLAZURE",
"ConnectionString":"Data Source=someting;Initial Catalog=rsadventureworks;Encrypt=True;TrustServerCertificate=False",
"IsConnectionStringOverridden":true,
"CredentialRetrieval":"store",
"CredentialsInServer":
{
"UserName":"something",
"Password":"something",
"UseAsWindowsCredentials":false,
"ImpersonateAuthenticatedUser":false
},
"CredentialsByUser":null
}
]

当时在我的测试中为我工作,虽然我还没有在我的部署解决方案中实现这个(我最初使用的是遗留的soap api,因为这个问题拖了一段时间)。

于 2020-11-25T16:01:11.613 回答