# 400 Bad Request in MERN Project, solution not found anywhere

**URL:** <https://community.postman.com/t/400-bad-request-in-mern-project-solution-not-found-anywhere/21674>\
**Category:** Help Hub\
**Created:** [March 22, 2021, 6:05am UTC](https://community.postman.com/t/400-bad-request-in-mern-project-solution-not-found-anywhere/21674 "2021-03-22T06:05:55Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![rohan.sinha1110](https://avatars.discourse-cdn.com/v4/letter/r/91b2a8/32.png) [@rohan.sinha1110](https://community.postman.com/u/rohan.sinha1110)\
**Post date:** [March 22, 2021, 6:05am UTC](https://community.postman.com/t/400-bad-request-in-mern-project-solution-not-found-anywhere/21674/1 "2021-03-22T06:05:55Z")

</div>

Hey! I’m doing this course on Udemy: [MERN Stack React Node Ecommerce from Scratch to Deployment](https://www.udemy.com/course/react-node-ecommerce/). Still in the initial phase. This is my User schema model:

```auto
const mongoose = require('mongoose');
const crypto = require('crypto');
const { v1: uuidv1 } = require('uuid');

const userSchema = new mongoose.Schema(
    {
        name: {
            type: String,
            trim: true,
            required: true,
            maxlength: 32
        },
        email: {
            type: String,
            trim: true,
            required: true,
            unique: true
        },
        hashed_password: {
            type: String,
            required: true
        },
        about: {
            type: String,
            trim: true
        },
        salt: String,
        role: {
            type: Number,
            default: 0
        },
        history: {
            type: Array,
            default: []
        }
    },
    { timestamps: true }
);

// virtual field for hashing pswd
userSchema
    .virtual('password')
    .set(function(password) {
        this._password = password;
        this.salt = uuidv1();
        this.hashed_password = this.encryptPassword(password);
    })
    .get(function() {
        return this._password;
    });

userSchema.methods = {
    authenticate: function(plainText) {
        return this.encryptPassword(plainText) === this.hashed_password;
    },

    encryptPassword: function(password) {
        if (!password) return '';
        try {
            return crypto
                .createHmac('sha1', this.salt)
                .update(password)
                .digest('hex');
        } catch (err) {
            return '';
        }
    }
};

module.exports = mongoose.model('User', userSchema);

```

Giving GET request is working fine, however POST is giving **400 Bad Request**.

 ![posterror](https://us1.discourse-cdn.com/getpostman/original/3X/d/7/d7f8a313bd331814423a3b6494876ae200c7f4e7.jpeg)

Acc to me, the syntax is correct. Then why the error?  
(Using Intellij IDE on Linux.)

Thanks in advance!

PS: I’m new to MERN etc.

---

<div class="post-metadata">

**Author:** ![thefierycoder](https://avatars.discourse-cdn.com/v4/letter/t/5fc32e/32.png) [@thefierycoder](https://community.postman.com/u/thefierycoder)\
**Post date:** [March 22, 2021, 6:17am UTC](https://community.postman.com/t/400-bad-request-in-mern-project-solution-not-found-anywhere/21674/3 "2021-03-22T06:17:34Z")

</div>

Hello there,  
Welcome to the community,

Please check [this thread](https://community.postman.com/t/400-bad-request/18252/5) to resolve your issue.  
and use lowercase H in localhost of your URL.

If you have any other questions, feel free to ask.  
Best Regards,  
Rishi Purwar

---

<div class="post-metadata">

**Author:** ![rohan.sinha1110](https://avatars.discourse-cdn.com/v4/letter/r/91b2a8/32.png) [@rohan.sinha1110](https://community.postman.com/u/rohan.sinha1110)\
**Post date:** [March 22, 2021, 6:22am UTC](https://community.postman.com/t/400-bad-request-in-mern-project-solution-not-found-anywhere/21674/4 "2021-03-22T06:22:39Z")

</div>

Hey Rishi  
None of the suggestions given in that post seem to be working for me.

---

<div class="post-metadata">

**Author:** ![thefierycoder](https://avatars.discourse-cdn.com/v4/letter/t/5fc32e/32.png) [@thefierycoder](https://community.postman.com/u/thefierycoder)\
**Post date:** [March 22, 2021, 6:23am UTC](https://community.postman.com/t/400-bad-request-in-mern-project-solution-not-found-anywhere/21674/5 "2021-03-22T06:23:35Z")

</div>

Please share the ss of your headers and params

---

<div class="post-metadata">

**Author:** ![rohan.sinha1110](https://avatars.discourse-cdn.com/v4/letter/r/91b2a8/32.png) [@rohan.sinha1110](https://community.postman.com/u/rohan.sinha1110)\
**Post date:** [March 22, 2021, 6:25am UTC](https://community.postman.com/t/400-bad-request-in-mern-project-solution-not-found-anywhere/21674/6 "2021-03-22T06:25:39Z")

</div>

Currently I’m checking only one field. But 404 persists even after checking other fields.

 ![headers](https://us1.discourse-cdn.com/getpostman/original/3X/b/a/bac6560c7b3daeca7f976da1d0a647f9c36cc32a.jpeg)

---

<div class="post-metadata">

**Author:** ![thefierycoder](https://avatars.discourse-cdn.com/v4/letter/t/5fc32e/32.png) [@thefierycoder](https://community.postman.com/u/thefierycoder)\
**Post date:** [March 22, 2021, 6:28am UTC](https://community.postman.com/t/400-bad-request-in-mern-project-solution-not-found-anywhere/21674/7 "2021-03-22T06:28:35Z")

</div>

please share the ss of params

---

<div class="post-metadata">

**Author:** ![rohan.sinha1110](https://avatars.discourse-cdn.com/v4/letter/r/91b2a8/32.png) [@rohan.sinha1110](https://community.postman.com/u/rohan.sinha1110)\
**Post date:** [March 22, 2021, 6:30am UTC](https://community.postman.com/t/400-bad-request-in-mern-project-solution-not-found-anywhere/21674/8 "2021-03-22T06:30:18Z")

</div>

It’s empty

 ![params](https://us1.discourse-cdn.com/getpostman/original/3X/d/a/da60002f5b0773f8888a74601d4bf95968e123b1.jpeg)

---

<div class="post-metadata">

**Author:** ![rohan.sinha1110](https://avatars.discourse-cdn.com/v4/letter/r/91b2a8/32.png) [@rohan.sinha1110](https://community.postman.com/u/rohan.sinha1110)\
**Post date:** [March 22, 2021, 6:32am UTC](https://community.postman.com/t/400-bad-request-in-mern-project-solution-not-found-anywhere/21674/9 "2021-03-22T06:32:36Z")

</div>

Also Authorization is at **NO AUTH**.

---

<div class="post-metadata">

**Author:** ![thefierycoder](https://avatars.discourse-cdn.com/v4/letter/t/5fc32e/32.png) [@thefierycoder](https://community.postman.com/u/thefierycoder)\
**Post date:** [March 22, 2021, 6:36am UTC](https://community.postman.com/t/400-bad-request-in-mern-project-solution-not-found-anywhere/21674/10 "2021-03-22T06:36:08Z")

</div>

have you tried this?  
and don’t uncheck any of the default headers and try again with the correct api url

 ![Screenshot 2021-03-22 at 12.05.19 PM](https://us1.discourse-cdn.com/getpostman/original/3X/9/7/9787d929a599f003bfa5ca7a4d3a6f97f81c42a9.png)

---

<div class="post-metadata">

**Author:** ![thefierycoder](https://avatars.discourse-cdn.com/v4/letter/t/5fc32e/32.png) [@thefierycoder](https://community.postman.com/u/thefierycoder)\
**Post date:** [March 22, 2021, 6:37am UTC](https://community.postman.com/t/400-bad-request-in-mern-project-solution-not-found-anywhere/21674/11 "2021-03-22T06:37:50Z")

</div>

create a new tab then try to run this signup request again with above mentioned content-type header

---

<div class="post-metadata">

**Author:** ![rohan.sinha1110](https://avatars.discourse-cdn.com/v4/letter/r/91b2a8/32.png) [@rohan.sinha1110](https://community.postman.com/u/rohan.sinha1110)\
**Post date:** [March 22, 2021, 6:39am UTC](https://community.postman.com/t/400-bad-request-in-mern-project-solution-not-found-anywhere/21674/12 "2021-03-22T06:39:51Z")

</div>

It worked! Thanks a lottt!

 ![POSTworked](https://us1.discourse-cdn.com/getpostman/original/3X/7/5/75516453511a20a75bd81dbc40d87c9bb0ce6365.jpeg)

---

<div class="post-metadata">

**Author:** ![thefierycoder](https://avatars.discourse-cdn.com/v4/letter/t/5fc32e/32.png) [@thefierycoder](https://community.postman.com/u/thefierycoder)\
**Post date:** [March 22, 2021, 6:41am UTC](https://community.postman.com/t/400-bad-request-in-mern-project-solution-not-found-anywhere/21674/13 "2021-03-22T06:41:45Z")

</div>

Keep up the good work👍
