无法从 Salesforce 流 http 标注(测试版)访问数组内的数组

问题描述 投票:0回答:1

在沙箱中,我尝试从 https://data.nasdaq.com/api/v3/datasets/USTREASURY/YIELD.json

收集信息

我使用了直接从流程中创建 HTTP 标注的测试版功能。它根据您提供的示例响应创建外部服务。

我的问题是,在创建的 JSON 中,数组中有数组;因为反应就像

"data":[["2023-02-02","4.62","4.65","4.66","4.76","4.64","4.09","3.75","3.49","3.44","3.4","3.67","3.55"]],

当我从流程中的标注访问响应时,数组 column_names 可用,但数组数据不可用。

创建的 JSON 是:

{"openapi":"3.0.1",
 "info":{"title":"dataNasdaqGetRates"
         ,"description":""},
 "paths":{"":{"get":{"description":"",
                     "operationId":"getRates",
                     "parameters":[{"name":"api_key","in":"query","required":true,"allowEmptyValue":false,
                                    "schema":{"type":"string"}},
                                   {"name":"order","in":"query","required":true,"allowEmptyValue":false,
                                    "schema":{"type":"string"}},
                                   {"name":"limit","in":"query","required":true,"allowEmptyValue":false,
                                     "schema":{"type":"integer","format":"int32"}}],
                     "responses":{"2XX":{"description":"",
                                         "content":{"application/json":{"schema":{"type":"object",
                                                                                  "properties":{"dataset":{"type":"object",
                                                                                                           "properties":{"end_date":{"type":"string"},
                                                                                                                         "data":{"type":"array",
                                                                                                                                 "items":{"type":"array",
                                                                                                                                          "items":{"type":"string"}}},
                                                                                                                         "description":{"type":"string"},
                                                                                                                         "newest_available_date":{"type":"string"},
                                                                                                                         "type":{"type":"string"},
                                                                                                                         "dataset_code":{"type":"string"},
                                                                                                                         "column_index":{"type":"string"},
                                                                                                                         "frequency":{"type":"string"},
                                                                                                                         "oldest_available_date":{"type":"string"},
                                                                                                                         "transform":{"type":"string"},
                                                                                                                         "premium":{"type":"boolean"},
                                                                                                                         "refreshed_at":{"type":"string"},
                                                                                                                         "database_id":{"type":"integer",
                                                                                                                                        "format":"int64"},
                                                                                                                         "database_code":{"type":"string"},
                                                                                                                         "name":{"type":"string"},
                                                                                                                         "limit":{"type":"integer","format":"int64"},
                                                                                                                         "id":{"type":"integer","format":"int64"},
                                                                                                                         "column_names":{"type":"array",
                                                                                                                                         "items":{"type":"string"}},
                                                                                                                         "collapse":{"type":"string"},
                                                                                                                         "start_date":{"type":"string"},
                                                                                                                         "order":{"type":"string"}
                                                                                                                        }}}}}}}}}}}}

我尝试调整 JSON 以删除嵌套数组,希望它能正常工作。我尝试向嵌套数组添加额外的“type”:(从技术上讲,第一项是字符串,其余是整数)。

我期望在columnx5fnames之后列出另一个名为“data”的顶点定义列表;甚至只是一个文本集合或任何我可以添加到变量和访问的东西。 response items menu from flow

arrays json salesforce http-get
1个回答
0
投票

您将需要创建一个 APEX 定义的集合变量,然后使用赋值元素分配 HTTP Callout 操作的输出。

Create a new collection variable. Allow Multiple Values = true, Data Type = Apex Defined

Choose the APEX class that ends with the name of your array (you may have many depending on the hierarchy of your schema). In my case it is

Then just assign the output from your HTTP Callout Action to the new variable you created

© www.soinside.com 2019 - 2024. All rights reserved.