English
Instant Developer Foundation Documentazione
  • Reference Librerie
  • Document Orientation
  • Web Api Service

Set Response

procedura copia link

Scopo

Questo metodo viene utilizzato durante una richiesta WebAPI (normalmente nell'evento OnWebApi) per impostare la risposta.

Sintassi

WebApiService.setResponse("content", statusCode, "mime-type")

Argomenti

Content Testo da inviare come risposta.
Status Code Codice di stato della risposta (vedi codici di stato del protocollo HTTP); se non specificato viene considerato 204 se l'argomento Content è vuoto, altrimenti 200.
Mime Type Mime-type del contenuto (es. application/json o text/xml); se non specificato verrà omesso anche nella risposta.

Esempio di codice

event MyDocHelper.GlobalDocumentWebAPI(
  IDDocument Document  // Source Document
  inout boolean Cancel // A boolean output parameter. If set to true it st...
)
{
  // Read username header
  IDMap requestHeaders = WebApiService.getHeaders()
  string username = requestHeaders.getValue("username")
  // 
  // Find the employee with this username

  int vIdEmployee = 0
  if (username != null)
  {
    select into variables (found variable)
      set vIdEmployee = EmployeeId
    from
      Employees // master table
    where
      LastName = username
  }
  // 
  // Employee not authorized; abort the request

  if (vIdEmployee == 0)
  {
    Cancel = true
    WebApiService.setResponse(formatMessage("User |1 not found", username, ...), 401
      , ...)
  }
}

Ultima modifica: 23/03/2021 / Validità: da 13.0.5600

Vedi Anche

  • On Web API (evento)

Hai trovato utile l'articolo?

Grazie per il feedback!

Ti serve altro aiuto?

Consulta il Forum