Clay Icon

how to add condition for empty response in an api call?

ยท
ยท

how to add condition for empty response in an api call?

  • Avatar of Channeled
    Channeled
    APP
    ยท
    ยท

    To handle an empty response in an API call, you can use conditional statements in Clay. Here's how: 1. Use the "Define field paths to return" option in the HTTP API integration setup. 2. Create a conditional statement to check for empty responses. For example: LBKSIF({{api_response}} == "") THEN "No data returned" ELSE {{api_response}}LBKSThis will return "No data returned" if the API response is empty, otherwise it will show the actual response. If you're experiencing JSON-related issues or "failed to parse body" errors, please copy and paste the JSON into the chat so we can troubleshoot further.

  • Avatar of Alex
    Alex
    ยท
    ยท

    does not work

  • Avatar of Summiya B.
    Summiya B.
    ยท
    ยท

    Go to your Clay table and click on the column where the API response is stored. Click "Add Column" and select "Formula." Use the following formula to check for empty values.. IF(NOT({API Response Column}), "No Data Found", {API Response Column}) Click "Save & Test" to verify.

  • Avatar of Daniel K.
    Daniel K.
    ยท
    ยท

    Hey there, thanks for reaching out! โ˜บ๏ธ You can try: If /{APIResponse} is empty If this doesn't work, can you share your table?

    (52 kB)
    Image
  • Avatar of Channeled
    Channeled
    APP
    ยท
    ยท