0

I am getting error while posting data from web API.

ExceptionMessage=Cannot insert explicit value for identity column in table 'Tbl_Menu' when IDENTITY_INSERT is set to OFF.

can anyone please tell how to resolve these error.

Anoop H.N
  • 1,244
  • 1
  • 15
  • 31
manish jadhav
  • 15
  • 2
  • 10
  • Possible duplicate of [IDENTITY\_INSERT is set to OFF - How to turn it ON?](http://stackoverflow.com/questions/3112579/identity-insert-is-set-to-off-how-to-turn-it-on) – Anoop H.N Mar 22 '17 at 06:28

1 Answers1

0

I Got Answer from my senior.

just change WebApiConfig File

config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

to

config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/**{action}**/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

and use url for post data

http://localhost:14795/api/Guest/PostTbl_Menu
manish jadhav
  • 15
  • 2
  • 10