Respond to webhook: "Unexpected end of JSON input"

Describe the problem/error/question

  • My workflow receives a webhook POST and is setup to respond once the “respond to webhook” node is complete.
  • In n8n, it seems that it sends the response correctly, but the receiving side (while receiving a response) sees an error “Unexpected end of JSON input” when it should receive the final JSON result with the availability slots.
  • I am monitoring the webhook via ngrok.
  • Hopefully I cleaned the information below well enough.

What is the error message (if any)?

Here is the raw JSON response from n8n that was captured via ngrok

HTTP/1.1 200 OK

Content-Type: application/json; charset=utf-8

Vary: Accept-Encoding

Date: Thu, 05 Sep 2024 22:01:23 GMT

Connection: keep-alive

Keep-Alive: timeout=5

Transfer-Encoding: chunked

0

Please share your workflow

Here is the JSON output from the ‘respond to webhook’ node

Share the output returned by the last node

[
  {
    "results": [
      {
        "toolCallId": "call_xxxxxxxx",
        "result": [
          {
            "start": "2024-09-04T09:00:00.000-05:00",
            "end": "2024-09-04T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-05T09:00:00.000-05:00",
            "end": "2024-09-05T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-06T09:00:00.000-05:00",
            "end": "2024-09-06T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-09T09:00:00.000-05:00",
            "end": "2024-09-09T13:00:00.000-04:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-10T09:00:00.000-05:00",
            "end": "2024-09-10T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-11T09:00:00.000-05:00",
            "end": "2024-09-11T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-12T09:00:00.000-05:00",
            "end": "2024-09-12T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-13T09:00:00.000-05:00",
            "end": "2024-09-13T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-16T09:00:00.000-05:00",
            "end": "2024-09-16T13:00:00.000-04:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-17T09:00:00.000-05:00",
            "end": "2024-09-17T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-18T09:00:00.000-05:00",
            "end": "2024-09-18T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-19T09:00:00.000-05:00",
            "end": "2024-09-19T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-20T09:00:00.000-05:00",
            "end": "2024-09-20T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-23T09:00:00.000-05:00",
            "end": "2024-09-23T13:00:00.000-04:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-24T09:00:00.000-05:00",
            "end": "2024-09-24T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-25T09:00:00.000-05:00",
            "end": "2024-09-25T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-26T09:00:00.000-05:00",
            "end": "2024-09-26T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-27T09:00:00.000-05:00",
            "end": "2024-09-27T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-30T09:00:00.000-05:00",
            "end": "2024-09-30T13:00:00.000-04:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-10-01T09:00:00.000-05:00",
            "end": "2024-10-01T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-10-02T09:00:00.000-05:00",
            "end": "2024-10-02T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-10-03T09:00:00.000-05:00",
            "end": "2024-10-03T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-10-04T09:00:00.000-05:00",
            "end": "2024-10-04T16:00:00.000-05:00",
            "name": "Available Time Slot"
          }
        ]
      }
    ]
  }
]

Information on your n8n setup

  • n8n version: 1.55.3
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): self hosted docker using this
  • Operating system: Win 10

Hey @Spectrem12 , your “Respond to Webhook” is configured to respond with the value of the previous node’s property AllAvailability. However, the previous node, namely “Set webhook response variables” does not have such a property. Thus, it sounds legitimate that the body in the HTTP response is not a valid JSON.

Am I missing anything? I believe “Respond to Webhook”'s body should have just {{ $json }}, not {{ $json.AllAvailability }} if you are to reply with the body provided in Share the output returned by the last node section of your post.

1 Like

@ihortom Thank you!

That fixed it.

Its a little confusing, b/c the output in the editor is still the same regardless if I use $json or $json.AllAvailability. Below is the output of the last node after I changed to $json.

[
  {
    "results": [
      {
        "toolCallId": "call_TBkcgEdVP8Rr19cLjNJiGlKf",
        "result": [
          {
            "start": "2024-09-04T09:00:00.000-05:00",
            "end": "2024-09-04T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-05T09:00:00.000-05:00",
            "end": "2024-09-05T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-06T09:00:00.000-05:00",
            "end": "2024-09-06T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-09T09:00:00.000-05:00",
            "end": "2024-09-09T13:00:00.000-04:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-10T09:00:00.000-05:00",
            "end": "2024-09-10T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-11T09:00:00.000-05:00",
            "end": "2024-09-11T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-12T09:00:00.000-05:00",
            "end": "2024-09-12T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-13T09:00:00.000-05:00",
            "end": "2024-09-13T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-16T09:00:00.000-05:00",
            "end": "2024-09-16T13:00:00.000-04:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-17T09:00:00.000-05:00",
            "end": "2024-09-17T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-18T09:00:00.000-05:00",
            "end": "2024-09-18T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-19T09:00:00.000-05:00",
            "end": "2024-09-19T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-20T09:00:00.000-05:00",
            "end": "2024-09-20T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-23T09:00:00.000-05:00",
            "end": "2024-09-23T13:00:00.000-04:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-24T09:00:00.000-05:00",
            "end": "2024-09-24T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-25T09:00:00.000-05:00",
            "end": "2024-09-25T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-26T09:00:00.000-05:00",
            "end": "2024-09-26T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-27T09:00:00.000-05:00",
            "end": "2024-09-27T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-09-30T09:00:00.000-05:00",
            "end": "2024-09-30T13:00:00.000-04:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-10-01T09:00:00.000-05:00",
            "end": "2024-10-01T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-10-02T09:00:00.000-05:00",
            "end": "2024-10-02T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-10-03T09:00:00.000-05:00",
            "end": "2024-10-03T16:00:00.000-05:00",
            "name": "Available Time Slot"
          },
          {
            "start": "2024-10-04T09:00:00.000-05:00",
            "end": "2024-10-04T16:00:00.000-05:00",
            "name": "Available Time Slot"
          }
        ]
      }
    ]
  }
]