Whenever I create a custom $resource action like this:
getEntityResource(): ng.resource.IResourceClass<IEntityResource> {
let addAction: ng.resource.IActionDescriptor = {
method: 'POST',
url: 'http://localhost:8085/api/entity/add'
}
return <ng.resource.IResourceClass<IEntityResource>>
this.$resource("http://localhost:8085/api/entity/:entityId", { id: '@id' }, {
add: addAction,
});
and execute it from the controller in this manner:
this.$mdDialog.hide(this.dataService
.getEntityResource()
.add(this.entity,
() => this.$state.reload()
));
the request is being sent as shown below:
Request URL:http://localhost:8085/api/entity/add?id=0
The webApi endpoint expects an entity object as a parameter rather than an id:
[HttpPost]
public Entity Add(Entity entity)
The issue lies in sending the post request with a string parameter (?id=0) instead of a JSON object.
What could be missing here?
Thank you.