-2

我正在尝试使用 set 和 append 变量准备一个变量值,该变量需要传递到复制活动的请求正文以从 API 获取数据。我需要一次从数据库中查找 100 个值并形成一个值数组,但是由于复制活动失败,“(引用)值被附加在值的开始、结束和中间。我是截至目前尝试前两个值。"[\"{\\\"RIC\\\":{\\\"Value\\\":\\\"FHN.N\\\"}}\",\"{\\\"RIC\\\":{\\\"Value\\\":\\\"0142.HK\\\"}}\"]"这是我得到的最终变量输出,我使用 @replace(string(variables('RIC')),'',' 删除了额外的 \ (斜杠) ') 并且输出是 -"[\"{\"RIC\":{\"Value\":\"FHN.N\"}}\",\"{\"RIC\":{\"Value\":\"0142.HK\"}}\"]"由于“在两个 RIC 值之间和 }] 之间的引号在开始和结束时失败。如果我可以得到输出为 "[{"RIC":{"Value":"FHN.N" }},{"RIC":{"Value":"0142.HK"}}]" 它将解决问题,因为我尝试手动传递它。

在复制活动中传递的请求正文 - "{"GetSignificantDevelopments_Request_1":{"FindRequest":{"CompanyIdentifiers_typehint":["CompanyIdentifiers","CompanyIdentifiers"],"CompanyIdentifiers":["{"RIC":{"Value":" FHN.N"}}","{"RIC":{"Value":"0142.HK"}}"],"StartDate":"2021-01-05T00:00:00","EndDate":" 2021-01-06T00:00:00","Significance":"1 2 3","MaxNumberOfItems": 100}}}",-这是失败的

手动尝试成功的请求正文 - "{"GetSignificantDevelopments_Request_1":{"FindRequest":{"CompanyIdentifiers_typehint":["CompanyIdentifiers","CompanyIdentifiers"],"CompanyIdentifiers":[{"RIC":{"Value":"FHN. N"}},{"RIC":{"Value":"0142.HK"}}],"StartDate":"2021-01-05T00:00:00","EndDate":"2021-01-06T00 :00:00","意义":"1 2 3","MaxNumberOfItems": 100}}}",

4

3 回答 3

1

The other way would be to use Replace function to replace all unwanted characters from the variable like : @replace(string(variables('RIC')),'','') where \ is just one of the characters. You can keep on concatenating replace functions to replace other characters and achieve your output. Hope this would be helpful :)

于 2021-01-07T10:16:48.273 回答
0

我使用了替换功能并获得了所需的输出。

@replace(replace(replace(replace(string(variables('RIC')),'\',''),'["{','[{'),'}"]','}]'),'}","{','},{')
于 2021-01-11T15:47:46.673 回答
0

很难转型"[\"{\"RIC\":{\"Value\":\"FHN.N\"}}\",\"{\"RIC\":{\"Value\":\"0142.HK\"}}\"]"。因为它不是有效的 JSON 数据。您可以尝试使用substring函数来获取两个 JSON 对象{"RIC":{"Value":"FHN.N"}}{"RIC":{"Value":"0142.HK"}}. 然后使用concat函数来编写您的请求正文,如下所示:

@{concat('{"GetSignificantDevelopments_Request_1":{"FindRequest":{"CompanyIdentifiers_typehint":["CompanyIdentifiers","CompanyIdentifiers"],"CompanyIdentifiers":[',json(substring(variables('RIC'),2,24)),',',json(substring(variables('RIC'),30,26)),'],"StartDate": "2021-01-05T00:00:00","EndDate": "2021-01-06T00:00:00","Significance": "1 2 3","MaxNumberOfItems": 100}}}')}
于 2021-01-07T05:25:33.667 回答