邮递员GET不传递参数 [英] Postman GET Doesn't Pass Parameters

查看:98
本文介绍了邮递员GET不传递参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用Postman进行简单的GET时,使用[FromUri]时参数不会转换为我的ASP.NET资源/模型对象。例如,当我在控制器的get中设置一个断点并使用GET通过邮递员调用此简单URL时,我看到未设置ID: http://example.net/api/product?Id=ee58d7c8-0288-48fb-bc28-3d38c344d834

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

为什么我的ID无法翻译?

Why is my Id not translated?

推荐答案

事实证明,我的控制器是设置正确,但是我没有在Postman中正确设置Content-Type标头。对于我的请求,我需要单击Postman中的Headers选项卡,并添加新行,其中Content-Type = application / json。通过正确设置,我的控制器能够将我的请求正确地转换为模型。

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.

这篇关于邮递员GET不传递参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆