Reputation: 68
I am trying to delete a specific task from my task queue using code from nodejs. i can't seem to find proper documentation on deleting a task. I only saw documentation on how to delete a queue. I tried the code below and it gives me an error.
delete = async (projectId) => {
const location = "us-central1";
const queue = this.queue_id;
// Get the fully qualified path to the queue
const name = client.queuePath(projectId, location, queue);
try {
const taskDelete = await client.deleteTask(name);
console.log("delete initiated for project id: ", projectId);
console.log(`deleted queue task: ${taskDelete}`);
} catch (error) {
console.log(error);
}
};
and i am getting eerror from console:
Error: 3 INVALID_ARGUMENT: Invalid resource field value in the request.
code: 3,
details: 'Invalid resource field value in the request.',
metadata: Metadata {
internalRepr: Map { 'grpc-server-stats-bin' => [Array] },
options: {}
},
note: 'Exception occurred in retry method that was not classified as transient'
}
confused as I am new to GPC
thank you and I apologize for the bad question
Upvotes: 0
Views: 642
Reputation: 15266
In your code, you care calling deleteTask from CloudTasksClient which is the right approach. However examine carefully the parameter you are passing to it. It seems to require an object of the format:
{
"name": "[projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID]"
}
You are passing a string (not an object) and the string is a queue resource and not a task resource.
I get the impression that what you want to code is:
const taskDelete = await client.deleteTask({
"name": client.taskPath(projectId, location, queue, taskId)
});
Upvotes: 2