Testare l'API REST di Configurazione app di Azure usando Postman
Per testare l'API REST usando Postman, è necessario includere le intestazioni HTTP necessarie per l'autenticazione nelle richieste. Ecco come configurare Postman per testare l'API REST, generando automaticamente le intestazioni di autenticazione:
Creare una nuova richiesta
Aggiungere la
signRequest
funzione dall'esempio di autenticazione JavaScript allo script di pre-richiesta per la richiestaAggiungere il codice seguente alla fine dello script di pre-richiesta. Aggiornare la chiave di accesso come indicato dal commento TODO
// TODO: Replace the following placeholders with your access key var credential = "<Credential>"; // Id var secret = "<Secret>"; // Value var isBodyEmpty = pm.request.body === null || pm.request.body === undefined || pm.request.body.isEmpty(); var headers = signRequest( pm.request.url.getHost(), pm.request.method, pm.request.url.getPathWithQuery(), isBodyEmpty ? undefined : pm.request.body.toString(), credential, secret); // Add headers to the request headers.forEach(header => { pm.request.headers.upsert({key: header.name, value: header.value}); })
Inviare la richiesta