Question: I have a method that receives some data from a 3rd party. The data is a JSON object (not a string, I tried receiving as a string and data was not accessable - the data property was null)

```
[HttpPost]
 [Route("com/sendemail")]
 public async Task<IActionResult> SendEmail(dynamic data)
 {
       mailData = JsonConvert.DeserializeObject<EmailTemplate>(data);
 }

```

I am trying to get it into a .net object which is needed to be passed into another function I dont control. It has to be an EmailTemplate object, which is defined as:

```
public class EmailTemplate
{
        public string From { get; set; }
        public string To { get; set; }
        public string Subject { get; set; }
        public string EmailHtml { get; set; }
}

```

mailData is of type EmailTemplate. The Deserialize object call fails because that method requires a string, which this isnt. Ive tried other methods, such as

```
mailData = (EmailTemplate)data;

```

and

```
mailData.To = data.To

```

but neither work. Any pointers gratefully received.

PS. Heres what the data looks like in visual studio

[![enter image description here](https://i.stack.imgur.com/xlCQM.png)](https://i.stack.imgur.com/xlCQM.png)

Answer: 
you can use id like Code below with least Changes in your code

```
    $input = request()->all();
    $input = Patient::create($input);
    dd($input->id);
    // return redirect()->route('medical.create',compact('input'));

```
you can retrive id after saving data by mass assignments :

```
 public function store(Request $request)
    {
        $input = request()->all();
        $patient = new Patient($input); // fill model with mass assignments
        $patient->save() // save instant
        $id = $patient->id; //retrive id

    }

```