the object content 1 type failed to serialize the response body for content type application/xml

Recently while working in a Web API call for our SharePoint online workflow app, I got the below url which says:

An error has occurred.
the ‘object content 1’ type failed to serialize the response body for content type ‘application/xml;charset=utf-8’.

The full error looks like below:

the object content 1 type failed to serialize the response body for content type application/xml

the object content 1 type failed to serialize the response body for content type application/xml



Read some sharepoint online tutorials:

I have written one method which took 3 parameters and returns an Object like below:

[HttpGet] public Object IsDocLinkNoneExist(string URL, string LN, string DT)
{
}

And also in the WebApiConfig we wrote like below:

config.Routes.MapHttpRoute(
name: “IsDocLinkNoneExist”,
routeTemplate: “api/{controller}/{action}/{URL}/{LN}/{DT}”,
defaults: new { controller = “MyWebAPIController”, action = “IsDocLinkNoneExist”, URL = “”, LN = “”, DT = “” }

);

Then I was trying to access the web api like below and it gave error like above:

https://mywebapi.azurewebsites.net/api/MyWebAPI/IsDocLinkNoneExist?URL=https://www.enjoysharepoint.com&LN=Hello&DT=MyTestDT

To resolve the issue I modified the code like below (added type=json attribute):

https://mywebapi.azurewebsites.net/api/MyWebAPI/IsDocLinkNoneExist?type=json&URL=https://www.enjoysharepoint.com&LN=Hello&DT=MyTestDT

Hopefully this will be helpful.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

>