0

I am trying to consume an api of this type:

 api / food_order / {id}

the idea is from a console project.

I found this code:

client.BaseAddress = new Uri ("http: // localhost: 1565 /");
var response = client.PutAsJsonAsync ("api / food_order", p) .Result;

the detail is that it sends the object p but the idea is to send the object p besides a string {id}

user9405863
  • 1,506
  • 1
  • 11
  • 16

1 Answers1

0

Since you have mentioned that you are trying to consume an api : api/food_order/{id}

Try changing to:

var response = client.PutAsJsonAsync($"api/food_order/{id}", p) .Result;

of if you are trying to pass the id as part of the body, try changing to:

var response = client.PutAsJsonAsync("api/food_order", new { Id = id, P = p }).Result;
Matt.G
  • 3,586
  • 2
  • 10
  • 23