Search code examples
javarestspring-mvcmodelrest-client

How to pass null parameters using ReSTClient API to the method for executing Web Service


I'm using WizTools.org RESTClient 3.2.2 & want to pass input parameters as

{
"user_id": "",
"user_email_id": "a@a.a",
"user_password": "fdsdsdf",
"firstname": "sdfsdf",
"lastname": "sfdsdfds",
"mobile_number": "1234567890",
"user_status": 1,
"isdeleted": 0,
"created_by": 1,
"profile_picturename": "kfksdjfhksjd",
"address": "sfdsdfsd"

}

Here to create an new record i want to pass user id as "user_id": "", but rest client is showing exception as "java.sql.SQLException: Incorrect integer value: '' for column 'pv_user_id' at row 44"

Can anyone suggest me how to pass null value to userID, my model class is as

@Column(name = "user_id")
private String user_id;
@Id
@Column(name = "user_email_id")
@NotEmpty(message = "Please enter your email_Id.")
@Email
@NotNull(message = "Enter last name")
private String user_email_id;
@NotEmpty(message = "Please enter your password.")
@Column(name = "user_password")
private String user_password;
@NotNull(message = "Enter last name")
@NotEmpty(message = "Please enter your firstName.")
@Column(name = "firstname")
private String firstname;
@NotNull(message = "Enter last name")
@NotEmpty(message = "Please enter your lastName.")
@Column(name = "lastname")
private String lastname;
// @NotNull
@NotEmpty
@Pattern(regexp = "(^[0-9]{10,12}$)", message = "Please enter your Mobile Number.")
@NumberFormat
// @Size(min = 10, max = 12)
@Column(name = "mobile_number")
private String mobile_number;
@Column(name = "user_status")
private Integer user_status;
@Column(name = "isdeleted")
private Integer isdeleted;
@Column(name = "created_by")
private Integer created_by;
@Column(name = "profile_picturename")
private String profile_picturename;
@Column(name = "address")
private String address;

Thanks in advance


Solution

  • If you'll not pass userId parameter it will take userId=null because userId is String and if you do not pass anything it will automatically take it as null.

    Even this link will be helpful to understand the reasons..

    What is a Java String's default initial value?