Getting "mysqli_sql_exception" Column "account_name" cannot be null" when I send a POST request JSON Body - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Monday, June 27, 2022

Getting "mysqli_sql_exception" Column "account_name" cannot be null" when I send a POST request JSON Body

I am creating a REST API with PHP CodeIgniter paired with a MYSQL Database. This is how my Database Table looks like. [enter image description here][1] [1]: https://ift.tt/x8iHlty

When I send a POST request with POSTMAN like: { "account_name": "Test User", "display_name": "Test", "phone_no": "6582323", "email": "jon@gmail.com" } The post request is successful.

But whenever I try to send a POST request by JSON Stringify, I get a Internal Server 500 error code, that says message: "Column 'account_name' cannot be null "title: "mysqli_sql_exception"

This is my POST request (AngularJS Frontend):

    let postData = {
            "account_name": "Test User",
            "display_name": "Test",
            "phone_no": "6582323",
            "email": "jon@gmail.com"
    }

    this.http.post("http://localhost:8080/api/user-info/create-user", JSON.stringify(postData), {headers: headers})
    .subscribe(data => {
      console.log(data);
     }, error => {
      console.log(error);
      console.log(postData)
    })
  }

I am struggling to find what the error might be. Any help will be highly appreciated.



source https://stackoverflow.com/questions/72764253/getting-mysqli-sql-exception-column-account-name-cannot-be-null-when-i-send

No comments:

Post a Comment