I am currently utilizing Angular version 1.4.8 along with Angular UI and TypeScript in my project. The models are defined as follows:
export interface IBatch extends ng.resource.IResource<IBatch> {
id: Number;
...
}
export interface IBatchResource extends ng.resource.IResourceClass<IBatch> {
snapshot(batch: IBatch);
}
I have configured my Batch
resource to include a custom HTTP verb TAKE-SNAPSHOT
, which can return either a 200 OK
or a 404 NOT FOUND
:
var paramDefaults = {
id: '@id'
};
var actions = {
'snapshot': { method: 'TAKE-SNAPSHOT' }
};
return <IBatchResource> this.$resource('/api/batches/:id', paramDefaults, actions);
This setup allows me to take a snapshot of a specific Batch by only providing the batch Id as a parameter for the API call. However, I've noticed that when using $resource
, it encodes the entire Batch
object into the query string, resulting in a very long URL (the actual length is over 1000 characters, but shortened here for clarity):
localhost:15000/api/batches/4?$originalData=%7B%22id%22:4,%22createdDateUtc%22:%222015-12-...
I am seeking guidance on how to direct the $resource
request specifically to localhost:15000/api/batches/4
.