I don't really have an idea how to use PUT method of web api passing the parameter from angular.
I understand how GET method executed but the PUT, POST and DELETE are really hard for me.
I read many articles but it i still dont get an idea
I have a code like this in controller in my web api:
static readonly IProfile profileRepository = new ProfileRepository();
[Route("api/profile/")]
[HttpGet]
[System.Web.Http.AcceptVerbs("GET")]
public IEnumerable<Profile> getProfiles()
{
return profileRepository.getProfiles();
}
[Route("api/profile/")]
[HttpPut]
[System.Web.Http.AcceptVerbs("PUT")]
public IEnumerable<Profile> putProfile(Profile profile)
{
profileRepository.putProfile(profile);
return getProfiles();
}
I also have like this in service in my angularJS
var _putProfile = function (name,address,contacts) {
return $http.put(serviceURL + 'api/profile/Name=' + name + '&Address=' + address + '&Contact=' + contacts).then(function (results) {
return results;
});
};
When i use Postman application the web api execute well when i use x-www-form-urlencoded and it passes data from postman to web api but how to pass data from angularJS to web api.
Is there anyone can give me a best answer here.. Please give me an idea how to do it and please advice me what is the best practice..
Im only new in angularJS and Web Api please guide me.. Thanks you so much