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: 
Need to specify the `@RequestBody` annotation to specify we are sending DOG object as part of request body:

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

```
Only works with objects so use Integer instead of int.