I am trying to post to a WCF json service endpoint from angular but have been unsuccessful in my attempts. I have verified the service is working by other means and working for the specified URL.
Using firebug I can see the request being output as such:
NetworkError: 400 Bad Request - http://www.myapi.com/V1/Service.svc/Authenticate?Password=password&UserName=username"
angular code
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
[WebInvoke(RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
Method = "POST",
BodyStyle = WebMessageBodyStyle.Wrapped)]
[OperationContract]
AuthenticateResponse Authenticate(AuthenticateRequest Request);
Request definition
[DataContract]
public class AuthenticateRequest
{
[DataMember]
public String UserName { get; set; }
[DataMember]
public String Password { get; set; }
}