# Error while posting to node js to SQL db

**URL:** <https://community.postman.com/t/error-while-posting-to-node-js-to-sql-db/63988>\
**Category:** Help Hub\
**Tags:** tests, development, json\
**Created:** [July 11, 2024, 3:56pm UTC](https://community.postman.com/t/error-while-posting-to-node-js-to-sql-db/63988 "2024-07-11T15:56:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mission-pilot-245071](https://avatars.discourse-cdn.com/v4/letter/m/839c29/32.png) [@mission-pilot-245071](https://community.postman.com/u/mission-pilot-245071)\
**Post date:** [July 11, 2024, 3:56pm UTC](https://community.postman.com/t/error-while-posting-to-node-js-to-sql-db/63988/1 "2024-07-11T15:56:31Z")

</div>

I get this error while posting to SQL:

```auto
C:\API\node_modules\mssql\lib\msnodesqlv8\request.js:276
        const err = new RequestError(info, 'EREQUEST')

```

```auto
app.post('/info/Post',(req,res)=>{
    console.log(req.body)
    res.send(req.body)

    let data = [req.body.ID, req.body.Name,req.body.Appointment,req.body.Technology,req.body.Task] ;
   
    sql.query('Insert into info(ID,Name,Appoinment,Technology,Task) values (?,?,?,?',data,(err,rows,fields)=>{
    if(!err)
    //console.log(rows);
    res.send('rows');
    else 
    console.log(err);
    })    
});

```

postman msg

```auto
{
    "ID":"30",
    "Name":"DG",
    "Appointment":"test",
    "Technology":"test",
    "Task":"test"
}

```

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [July 11, 2024, 4:36pm UTC](https://community.postman.com/t/error-while-posting-to-node-js-to-sql-db/63988/2 "2024-07-11T16:36:41Z")

</div>

Hey @mission-pilot-245071 👋

Welcome to the Postman Community! :postman:

This feels more likely a Stackoverflow question than something the would be answered on this forum but I think it might be a syntax error:

```auto
'Insert into info(ID,Name,Appoinment,Technology,Task) values (?,?,?,?'

```

I think you haven’t closed off the _values_ correctly, it should have a `)` before the last quote.

It also looks like you have a miss match on the word _Appointment_

---

<div class="post-metadata">

**Author:** ![mission-pilot-245071](https://avatars.discourse-cdn.com/v4/letter/m/839c29/32.png) [@mission-pilot-245071](https://community.postman.com/u/mission-pilot-245071)\
**Post date:** [July 11, 2024, 4:51pm UTC](https://community.postman.com/t/error-while-posting-to-node-js-to-sql-db/63988/3 "2024-07-11T16:51:32Z")

</div>

Thanks for the reply! I saw the missing close bracket and the miss match word. I corrected those and the same error.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [July 11, 2024, 4:58pm UTC](https://community.postman.com/t/error-while-posting-to-node-js-to-sql-db/63988/4 "2024-07-11T16:58:22Z")

</div>

> [@mission-pilot-245071](#):
>
> `res.send(req.body)`

Is this needed?

Wouldn’t that try and send a response before the SQL query completes?

---

<div class="post-metadata">

**Author:** ![mission-pilot-245071](https://avatars.discourse-cdn.com/v4/letter/m/839c29/32.png) [@mission-pilot-245071](https://community.postman.com/u/mission-pilot-245071)\
**Post date:** [July 11, 2024, 5:00pm UTC](https://community.postman.com/t/error-while-posting-to-node-js-to-sql-db/63988/5 "2024-07-11T17:00:19Z")

</div>

I added that just to test what’s being sent to node.

---

<div class="post-metadata">

**Author:** ![mission-pilot-245071](https://avatars.discourse-cdn.com/v4/letter/m/839c29/32.png) [@mission-pilot-245071](https://community.postman.com/u/mission-pilot-245071)\
**Post date:** [July 11, 2024, 5:02pm UTC](https://community.postman.com/t/error-while-posting-to-node-js-to-sql-db/63988/6 "2024-07-11T17:02:21Z")

</div>

on postman this is the error:  
Error: read ECONNRESET

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [July 11, 2024, 5:14pm UTC](https://community.postman.com/t/error-while-posting-to-node-js-to-sql-db/63988/7 "2024-07-11T17:14:00Z")

</div>

It’s not a _Postman_ error as such, you just happen to be using Postman to see the response from your server or lack of response in this case.

As I mentioned previously, this is a question that’s better asked on Stack Overflow as you would get a wider range of people with the necessary experience to answer the question.

These might help:

> <https://stackoverflow.com/questions/17245881/how-do-i-debug-error-econnreset-in-node-js>

> <https://stackoverflow.com/questions/17245881/how-do-i-debug-error-econnreset-in-node-js/17637900#17637900>

---

<div class="post-metadata">

**Author:** ![mission-pilot-245071](https://avatars.discourse-cdn.com/v4/letter/m/839c29/32.png) [@mission-pilot-245071](https://community.postman.com/u/mission-pilot-245071)\
**Post date:** [July 11, 2024, 5:17pm UTC](https://community.postman.com/t/error-while-posting-to-node-js-to-sql-db/63988/8 "2024-07-11T17:17:36Z")

</div>

Thanks! I will check that out.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [August 10, 2024, 5:18pm UTC](https://community.postman.com/t/error-while-posting-to-node-js-to-sql-db/63988/9 "2024-08-10T17:18:00Z")

</div>

Closed on August 10, 2024, 5:18pm UTC

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