0

I have a webapi method and below $http service call in angular app :-

[HttpPost]
Public Employee Getdata ([FROMBODY] XElement  objxml)
{ }


$http({
url : wwww.google.com,
method : 'POST',
data : $.param({
        xml: vm.inputxml
       }),
headers : {'Content-Type' : 'application/xml'}
})

The vm.inputxml is nothing but xml pasted on html page.

The problem here is webapi throws an error as, "There was an error deserializing the object of type system.xml.linq.Xelement , The data at root level is invalid".

Can you please suggest a way how can we send xml from angular to webapi. The web api input type Xlelement can not be changed or it can accept only xml type as xmlreader etc. but the i/p can not be changed to string. Please Suggest the way.. will be very thankful for the help.

Navin Rane
  • 31
  • 1
  • 1
  • 6

1 Answers1

0

Try it with using it directly:

$http({
    url : wwww.google.com,
    method : 'POST',
    data : vm.inputxml,
    headers : {'Content-Type' : 'application/xml'}
})

See: POST-ing XML in AngularJS

YaennuuH
  • 19
  • 2