Crie um novo gatilho de tarefa na impressora especificada. Atualmente, apenas um gatilho de tarefa pode ser especificado por impressora, mas esse limite pode ser removido no futuro.
Nota: O appId usado para gerar um token de acesso para criar um gatilho de tarefa deve ser o mesmo appId usado para criar a definição de tarefa correspondente.
Escolha a permissão ou as permissões marcadas como menos privilegiadas para essa API. Use uma permissão ou permissões privilegiadas mais altas somente se o aplicativo exigir. Para obter detalhes sobre permissões delegadas e de aplicativo, consulte Tipos de permissão. Para saber mais sobre essas permissões, consulte a referência de permissões.
No corpo da solicitação, forneça uma representação JSON de um objeto printTaskTrigger . Forneça uma referência a um printTaskDefinition usando o @odata.bind formato, conforme mostrado no exemplo a seguir.
Resposta
Se for bem-sucedido, esse método retornará um 201 Created código de resposta e um printTaskTrigger no corpo da resposta.
POST https://graph.microsoft.com/v1.0/print/printers/{printerId}/taskTriggers
Content-Type: application/json
{
"event": "jobStarted",
"definition@odata.bind": "https://graph.microsoft.com/v1.0/print/taskDefinitions/{taskDefinitionId}"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new PrintTaskTrigger
{
Event = PrintEvent.JobStarted,
AdditionalData = new Dictionary<string, object>
{
{
"definition@odata.bind" , "https://graph.microsoft.com/v1.0/print/taskDefinitions/{taskDefinitionId}"
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Print.Printers["{printer-id}"].TaskTriggers.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewPrintTaskTrigger()
event := graphmodels.JOBSTARTED_PRINTEVENT
requestBody.SetEvent(&event)
additionalData := map[string]interface{}{
"definition@odata.bind" : "https://graph.microsoft.com/v1.0/print/taskDefinitions/{taskDefinitionId}",
}
requestBody.SetAdditionalData(additionalData)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
taskTriggers, err := graphClient.Print().Printers().ByPrinterId("printer-id").TaskTriggers().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
PrintTaskTrigger printTaskTrigger = new PrintTaskTrigger();
printTaskTrigger.setEvent(PrintEvent.JobStarted);
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("definition@odata.bind", "https://graph.microsoft.com/v1.0/print/taskDefinitions/{taskDefinitionId}");
printTaskTrigger.setAdditionalData(additionalData);
PrintTaskTrigger result = graphClient.print().printers().byPrinterId("{printer-id}").taskTriggers().post(printTaskTrigger);
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.print_task_trigger import PrintTaskTrigger
from msgraph.generated.models.print_event import PrintEvent
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = PrintTaskTrigger(
event = PrintEvent.JobStarted,
additional_data = {
"definition@odata_bind" : "https://graph.microsoft.com/v1.0/print/taskDefinitions/{taskDefinitionId}",
}
)
result = await graph_client.print.printers.by_printer_id('printer-id').task_triggers.post(request_body)