MetricSign
EN|NLRequest Access
High severityexecution

Power BI Refresh Error:
002140

What does this error mean?

Snowflake received an error response from the external API endpoint when invoking an external function, often because the remote service returned a non-200 HTTP status or an unexpected payload format.

Common causes

  • 1The external API endpoint returned a 4xx or 5xx HTTP status code
  • 2The API gateway (AWS API Gateway, Azure API Management) rejected the request due to throttling or auth failure
  • 3The response payload from the remote service did not match the expected JSON array format Snowflake requires
  • 4The external function's MAX_BATCH_ROWS setting sends too many rows, exceeding the API payload size limit

How to fix it

  1. 1Step 1: Run the external function with a single test row and inspect the error details in the Snowflake query history.
  2. 2Step 2: Check the API gateway logs for the actual HTTP response code and body returned to Snowflake.
  3. 3Step 3: Verify the remote service is healthy and the API endpoint URL has not changed.
  4. 4Step 4: Confirm the Snowflake API integration IAM role or Entra app still has permission to invoke the API gateway.
  5. 5Step 5: Reduce MAX_BATCH_ROWS on the external function if payload size is causing gateway rejections.

Frequently asked questions

What HTTP response format does Snowflake expect from an external function?

Snowflake expects a JSON object with a 'data' key containing an array of [row_number, result] pairs — for example: {"data": [[0, "result1"], [1, "result2"]]}.

Can I test an external function before deploying it in production?

Yes — use a development Snowflake account or a separate external function pointing to a test API endpoint. You can also call the function directly with SELECT my_ext_function(test_value) and inspect the output.

Other execution errors