如何使用 POSTMAN 或任何客户端工具应用程序使用自定义对象调用 RestFul WCF POST 服务?

How to call RestFul WCF POST service With Custom Object using POSTMAN or any client tool application?

好吧,假设我想使用 POSTMAN 或任何其他 Rest 服务客户端工具来调用我的代码,我应该怎么做?我的参数之一是 SwitchStatus(这是我自己定义的某个对象)

使用 POSTMAN 调用此服务时,我是否应该在请求正文中包含一些内容?如果是这样,格式是什么? 任何帮助将不胜感激

谢谢

        [WebInvoke(UriTemplate = "/SwitchStatus", Method = "POST")]
        [OperationContract]
        [Description("Request to update switch status, true for close the switch")]
        void UpdateSwitchStatus(SwitchStatus data);

我希望我的服务器收到来自 POSTMAN 的请求。

哥们,你说的对,我们应该考虑是否包含参数的名称。其实是由Bodystyle决定的属性.

[OperationContract]
        [WebInvoke(RequestFormat =WebMessageFormat.Json,ResponseFormat =WebMessageFormat.Json,BodyStyle =WebMessageBodyStyle.Bare)]
        CompositeType GetDataUsingDataContract(CompositeType composite);

    [DataContract]
    public class CompositeType
    {
        bool boolValue = true;
        string stringValue = "Hello ";

        [DataMember]
        public bool BoolValue
        {
            get { return boolValue; }
            set { boolValue = value; }
        }

        [DataMember]
        public string StringValue
        {
            get { return stringValue; }
            set { stringValue = value; }
        }
}

根据上面的BodyStyle属性,请求body是,

{"StringValue":"Hello","BoolValue":true}  


请参考我之前的回复。里面有细致的描述。

如果有什么我可以帮忙的,请随时告诉我。