# When I try to create two posts via API at the same time. errors happen

**URL:** <https://meta.discourse.org/t/when-i-try-to-create-two-posts-via-api-at-the-same-time-errors-happen/135262>\
**Category:** Support\
**Created:** [December 6, 2019, 2:28pm UTC](https://meta.discourse.org/t/when-i-try-to-create-two-posts-via-api-at-the-same-time-errors-happen/135262 "2019-12-06T14:28:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![NathanLei](https://avatars.discourse-cdn.com/v4/letter/n/6bbea6/32.png) [@NathanLei](https://meta.discourse.org/u/NathanLei)\
**Post date:** [December 6, 2019, 2:28pm UTC](https://meta.discourse.org/t/when-i-try-to-create-two-posts-via-api-at-the-same-time-errors-happen/135262/1 "2019-12-06T14:28:18Z")

</div>

When I try to create two posts via API at the same time. errors happen  
`RangeError: Maximum call stack size exceeded`

I wonder if this is a setting issue or the API doesn’t support Parallel request.

I create post with promise.all() via API.

---

<div class="post-metadata">

**Author:** ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)\
**Post date:** [December 6, 2019, 2:29pm UTC](https://meta.discourse.org/t/when-i-try-to-create-two-posts-via-api-at-the-same-time-errors-happen/135262/2 "2019-12-06T14:29:22Z")

</div>

Where do you see that error? I suspect it is coming from your client application, rather than Discourse.

---

<div class="post-metadata">

**Author:** ![NathanLei](https://avatars.discourse-cdn.com/v4/letter/n/6bbea6/32.png) [@NathanLei](https://meta.discourse.org/u/NathanLei)\
**Post date:** [December 6, 2019, 2:38pm UTC](https://meta.discourse.org/t/when-i-try-to-create-two-posts-via-api-at-the-same-time-errors-happen/135262/3 "2019-12-06T14:38:37Z")

</div>

this is my code..

```
 let promise1 = post('posts', {
        topic_id: 35,
        raw: 'post1post1post1post1post1post1',
    })

    let promise2 = post('posts', {
        topic_id: 35,
        raw: 'post2post2post2post2post2',
    })

    try {
        let r = await Promise.all([promise1, promise2]).then()
        console.log('两个请求的返回' + JSON.stringify(r) )
        return r
    } catch (error) {
        console.log('error' + JSON.stringify(error) )
    }

```

the reture message is `Request failed with status code 422"`

---

<div class="post-metadata">

**Author:** ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)\
**Post date:** [December 6, 2019, 2:41pm UTC](https://meta.discourse.org/t/when-i-try-to-create-two-posts-via-api-at-the-same-time-errors-happen/135262/4 "2019-12-06T14:41:37Z")

</div>

422 likely means that the validation is failing on the post. You should log the response body from the http request, and check what the full error message is.

---

<div class="post-metadata">

**Author:** ![NathanLei](https://avatars.discourse-cdn.com/v4/letter/n/6bbea6/32.png) [@NathanLei](https://meta.discourse.org/u/NathanLei)\
**Post date:** [December 10, 2019, 9:56am UTC](https://meta.discourse.org/t/when-i-try-to-create-two-posts-via-api-at-the-same-time-errors-happen/135262/5 "2019-12-10T09:56:25Z")

</div>

I apologize, discourse support Parallel request, it was my bad. sorry

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [January 9, 2020, 10:00am UTC](https://meta.discourse.org/t/when-i-try-to-create-two-posts-via-api-at-the-same-time-errors-happen/135262/6 "2020-01-09T10:00:35Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
