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

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’.

SharePoint deveopment training course

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=http://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=http://www.enjoysharepoint.com&LN=Hello&DT=MyTestDT

Hopefully this will be helpful.

Check out Best Alternative to InfoPath -> Try Now

free sharepoint training

SharePoint Online FREE Training

JOIN a FREE SharePoint Video Course (3 Part Video Series)

envelope
envelope

About Bhawana Rathore

Hello Everyone!! I am Bhawana a SharePoint MVP and having about 8+ years of SharePoint experience as well as in .Net technologies . I have worked in all the versions of SharePoint from wss to Office 365. I have good exposure in Customization and Migration using Nintex, Metalogix tools . Now exploring more in SharePoint 2016 :) Hope here I can contribute and share my knowledge to the fullest. As I believe "There is no wealth like knowledge, and no poverty like ignorance"

View all posts by Bhawana Rathore →