I've been trying to send a request to a WCF JSON service endpoint from Angular, but I haven't had any luck so far. The service has been tested through other methods and is functioning properly for the specified URL.
When checking with Firebug, I can see the request being sent like this:
NetworkError: 400 Bad Request - "
Angular code snippet
app.service('UserService', function ($http) {
this.GetLoginStatus = function (AuthenticateRequest) {
$http({
url: APIURL + "/Authenticate",
method: "POST",
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
params: AuthenticateRequest,
data: {
'Code': 'test data'
}
});
};
WCF Iservice Configuration
[WebInvoke(RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
Method = "POST",
BodyStyle = WebMessageBodyStyle.Wrapped)]
[OperationContract]
AuthenticateResponse Authenticate(AuthenticateRequest Request);
Definition of the Request object
[DataContract]
public class AuthenticateRequest
{
[DataMember]
public String UserName { get; set; }
[DataMember]
public String Password { get; set; }
}