Skip to content
Loading
  • 0
    Thanks a lot Abdussami Khan .
    i have already tried by passing the id parameter in URL along with formated string for class object it was worked. how can we pass the id parameter as post parameter rather than passing in the URl. what change do i need to do in API method. 
    0
  • Abdussami Khan
    0
    If you want to send this ID parameter from body then create a new model and create two properties one for Id and second for EmployeeModel like ;
     
    Code
       public class CombinedModel
    Code
         {
    Code
          public int Id { get; set; }
    Code
          public EmployeeModel EmployeeModel { get; set; }
    Code
         }
     
     
     
     
    Change your API method ;
     
    Code
    public void Put([FromBody]JToken combinedModel)
    Code
     {
    Code
    //Here you have your model with Id and employeeObject in it
    Code
      CombinedModel model = JsonConvert.DeserializeObjectCombinedModel>(combinedModel.ToString());
    Code
    }
    0