Showing posts with label rest. Show all posts
Showing posts with label rest. Show all posts

Tuesday, December 23, 2014

[Resolved] WEBAPI ERROR using Json: The 'ObjectContent`1' type failed to serialize the response body for content type 'application/xml; charset=utf-8'.

hi lets see  how to resolve below error occurred while accessing web api for Json datatype :


 The 'ObjectContent`1' type failed to serialize the response body for content type 'application/xml; charset=utf-8'.



Solution:

go to global.asax file and in Application_Start() event add this below line.

GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
            GlobalConfiguration.Configuration.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter); 


After this u shud b able to run the webapi

Output:




Monday, September 8, 2014

Creating Restful Services/API using the Slim Framework for PHP || Calling API using Jquery

I was trying to create Rest Api using PHP , then i came across this Slim framework for php, which lets us create powerful APIs.

This below link shows how to create RESTful API using Slim framework and also how to call that api using Jquery.