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.

1
  • Could be encoding issue Commented May 23, 2017 at 8:29

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.