Question: ```
 public class Dog {
   private String name;
   private int weight;
     //...getters and
    //setters and constructor 
 }

```

Controller:

```
 @RequestMapping(value = "/dogs", method = RequestMethod.POST, 
 produces = "application/json")
 public void createDog(Dog dog) {
    dr.save(dog); 
 }

```

How come when I call the endpoint with json `{"name":"bark", "weight":50}`
I get an error:

> 
> Failed to convert value of type 'null' to required type 'int'; nested
> exception is
> org.springframework.core.convert.ConversionFailedException: Failed to
> convert from type [null] to type [int] for value 'null'; nested
> exception is java.lang.IllegalArgumentException: A null value cannot
> be assigned to a primitive type",
> "objectName": "dog",
> "field": "weight",
> "rejectedValue": null,
> "bindingFailure": true,
> "code": "typeMismatch"
> 
> 
> "message": "Validation failed for object='dog'. Error count: 1
> 
> 
> 

edit: I get the same issue with booleans and doubles. I guess I have to use objects not primitives?

Answer: 
Add the annotation `@RequestBody` to the param `dog` in your `create` method
If exist possibility object receive null, you can't use type primitives, same int, char, boolean.

```
private int weight

```

Use type objects same Integer, Boolean ... for one type primitive has a Object, then can receive null value.