WcfRestfulServices在Postman中传递参数而不是Body而不是QueryString

时间:2017-03-21 06:11:54

标签: c# postman wcf-rest

当我通过邮递员中的查询字符串传递参数来点击我的 Wcfrestfulservices 时,它工作正常。 客户端POSTMAN ::

http://localhost:12345/InvestUtiServices.svc/GetFoliosbyPAN?ApplicationID=jdhd@dkj&Password=ddjkk3ODkk-JhifhR7t4/k=&AppVersion=5.0&DeviceDetails=10.134.4.44&Source=website&PAN=BDXFD2F

服务中的

public Stream GetFoliosbyPAN(string ApplicationID, string Password, string AppVersion, string DeviceDetails, string Source, string PAN)

但是根据客户端的要求,我们不应该仅通过查询字符串来传递参数。 喜欢Postman身体:

http://localhost:51462/InvestUtiServices.svc/GetFoliosbyPAN
{
"ApplicationID" : "dfdfd",
"Password" : "sddf",
"AppVersion" : "5.0",
"DeviceDetails" : "10.333.3.33",
"Source" : "website",
"PAN" : "dfdddf"
}

但是值没有传递,我们在点击服务时会得到空值。

如何在POSTMAN中传递来自body的值?

提前致谢。Parameters apart from body

1 个答案:

答案 0 :(得分:1)

首先,您的方法必须是POST方法,然后才会接受post参数。

其次,您将参数作为JSON对象传递

cordova run

因此,您需要更改使用包含所有参数作为属性的复杂对象的方法声明

来自

{
"ApplicationID" : "dfdfd",
"Password" : "sddf",
"AppVersion" : "5.0",
"DeviceDetails" : "10.333.3.33",
"Source" : "website",
"PAN" : "dfdddf"
}

public Stream GetFoliosbyPAN(string ApplicationID, string Password, string AppVersion, string DeviceDetails, string Source, string PAN)

其中UserInfo将是一个以参数作为属性的类。

相关问题