does anyone knows why Iam getting error 400 for ajax request when Iam sending array. The strange thing for me is that in visual studio it works fine, but when uploaded project to hosting, started to get this type of error.
What Iam doing is creating array by this way:
SharedImages.push({ PathToFile: "/Images/image.png", ContentType: "png", FileName: "image"});
Using ajax:
type: "POST",
url: url + "ajaxrequest" ,
data: JSON.stringify({
CountryId: 1,
CityId: 1,
Place: "1",
SharedImages: SharedImages //aray of objects without this line all works fine
}),
contentType: 'application/json; charset=utf-8',
dataType: 'json',
crossDomain: true,
cache: false,
success: function
and get it in another class:
[OperationContract(Name = "ajaxrequest")]
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
public string ajaxrequest(int CountryId, int CityId, string Place, List<SharedImages> SharedImages)
{
}
SharedImages class lokes like
public class SharedImages{
public string PathToFile { get; set; }
public string ContentType { get; set; }
public string FileName { get; set; }}