formatDataAsArray outputs [object Object] in REST Query

I'm trying to make a REST Query and the data in the request is not being submitted correctly.

I'm using formatDataAsArray() to structure the results of another data query into a usable format for the API request:

{
   //... all other inputs from my Retool form
   "claim_history_table": {{formatDataAsArray(getClaimHistoryRecords.data)}},
}

getClaimHistoryRecords.data is a SQL query to get specific records. When I hover over it, the records show up correctly. For example, here is the result for claim_history_table:
Screenshot 2023-06-12 at 4.27.10 PM

However, when I submit the request, the output of formatDataAsArray() is [object Object]. See claim_history_table, in_transit_table, and stock_location_table as examples.

{
  "request_data": {
    "inputs": {
      "benchmark_premium": 1600000,
      "broker_name": a broker,
      "cat_exposure": 0,
      "cat_tool": ,
      "cat_uw_adjustment": 0,
      "cat_value": 0,
      "claim_history_table": [object Object],
      "claim_history_years": 0,
      "commission": 0,
      "date_file": 2023-06-12T15:56:02.150-0600,
      "est_loss_ratio": 0,
      "history_premium_is_known": FALSE,
      "in_transit_table": [object Object],[object Object],[object Object],
      "inception_date": null,
      "insured_name": some name,
      "previous_plan_estimated_premium": 0,
      "previous_plan_is_renewal": FALSE,
      "previous_plan_storage_avg_limit": 0,
      "previous_plan_storage_tiv": 0,
      "previous_plan_turnover_transit": 0,
      "stock_adjustment": -0.25,
      "stock_location_table": [object Object],[object Object],[object Object],
      "total_turnover_transit": 1220000000,
      "transit_adjustment": -0.25,
      "underwriter_name": a name
    }
  },
}

There are no transformers enabled.

Any ideas why this isn't working?

Hey @mead5432!

Would you mind sharing a full screenshot of your query? How the array gets interpreted depends on the context that it's in.

You might want to try and alter how you're passing the data or try using {{ JSON.stringify(formatDataAsArray(getClaimHistoryRecords.data)) }}.

Some fields expect strings, and when that's the case arrays and other objects can get turned into the string [object Object] (more on that here!). Even if the field has some object detection, if you format your input so that it's not exactly JSON format it can default to try to read it as string. In either case JSON.stringify should help but it may also be easier to input the value in a different way.

Let me know what you've found!