Postman GET Doesn't Pass Parameters

2019-09-12 23:41发布

问题:

When I try to do a simple GET using Postman, the parameters are not translated into my ASP.NET resource/model object when using [FromUri]. For example, when I set a breakpoint in the get of my controller and call this simple url via postman using GET, I see that the Id is not set: http://example.net/api/product?Id=ee58d7c8-0288-48fb-bc28-3d38c344d834

Why is my Id not translated?

回答1:

As it turns out, my controller was set up correctly, but I had not properly set up the Content-Type header in Postman. For my request, I need to click on on the Headers tab in Postman and add a new line where Content-Type = application/json. With this properly set up, my controller was able to properly translate my request into my model.