okay lets say I want to use POSTMAN or any other Rest service client tool to call my code, how should can I do it? one of my parameters is SwitchStatus (it's some object i defined myself)
When calling this service with POSTMAN, should I include something within the body of the request? If so, what will be the format? any help would be appreciated it
Thanks
[WebInvoke(UriTemplate = "/SwitchStatus", Method = "POST")]
[OperationContract]
[Description("Request to update switch status, true for close the switch")]
void UpdateSwitchStatus(SwitchStatus data);
I will expect my server to receive the request from POSTMAN.
Buddy, You are right, we should consider whether including the name of the parameter. Actually it is determined by the Bodystyle property.
[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; }
}
}
Depending on the above BodyStyle property, the request body is,
{"StringValue":"Hello","BoolValue":true}
Please refer to my previous reply. There is a meticulous description in it.
Get the object is null using JSON in WCF Service
Feel free to let me know if there is anything I can help with.