Zapier POST with error "body used already for"
Asked Answered
A

1

12

Basically following the code example verbatim, but trying to make a POST request with fetch

fetch('YOUR URL HERE', { method: 'POST', 'body': content })
    .then(function (res) {
        console.log(res.text());
        return res.text();
    })
    .then(function (plain) {
        var output = { okay: true, raw: plain };
        callback(null, output);
    })
    .catch(callback);

Results in angry red box with:

We had trouble sending your test through. Please try again. Error: Error: body used already for: https://YOURURLHERE

Not sure what it means?

Aboveboard answered 7/6, 2018 at 3:44 Comment(0)
A
23

...and then I realized it's not a Zapier question, but a fetch issue.

Google says it's because of what I'm doing in the promise, by trying to read the res stream as text twice (note the two res.text() calls).

(for about 2 minutes I had omitted what I thought was an unimportant detail from the question, the console.log line which was the culprit)

Aboveboard answered 7/6, 2018 at 3:50 Comment(1)
That's right! You could achieve the same result with console.log(plain)Gait

© 2022 - 2024 — McMap. All rights reserved.