Histórico da Página
...
Nome | Descrição |
---|---|
ok | Cria um retorno positivo com o payload e com o código do status HTTP 200 (é possível informar um status). |
asError | Cria um retorno de erro com uma lista erros da RowErrors e RowErrors e com o código do status HTTP informado500 (é possível informar um status). |
asWarning | Cria um retorno positivo com uma lista warnings da RowErrors e com o código do status HTTP 200 (é possível informar um status). |
empty | Cria um retorno vazio e com o código do status HTTP 200 (é possível informar um status). |
...
Bloco de código | ||
---|---|---|
| ||
... DEFINE OUTPUT PARAM jsonOutput AS JsonObject NO-UNDO. DEFINE VARIABLE oJsonObject AS JsonObject NO-UNDO. ASSIGN oJsonObject = NEW JSONObject(). jsonOutput = JsonAPIResponseBuilder:ok(oJsonObject). /* ou */ jsonOutput = JsonAPIResponseBuilder:ok(oJsonObject, 201). /* retorna status 201 */ /* ou */ jsonOutput = JsonAPIResponseBuilder:ok(oJsonObject, TRUE). /* existencia de próximo registro */ ... |
Bloco de código | ||
---|---|---|
| ||
... DEFINE OUTPUT PARAM jsonOutput AS JsonObject NO-UNDO. DEFINE VARIABLE oResponse oAppError AS JsonAPIResponseProgress.Lang.AppError NO-UNDO. ASSIGN oJsonObjectoAppError = NEW JSONObject(). Progress.Lang.AppError(). oAppError:AddMessage("Descrição do Erro", 1). jsonOutput = JsonAPIResponseBuilder:asError(oAppError). /* ou */ jsonOutput = JsonAPIResponseBuilder:ok(oJsonObject).asError(oAppError, 401). /* retorna status 401 */ ... |
Bloco de código | ||
---|---|---|
| ||
... DEFINE OUTPUT PARAM jsonOutput AS JsonObject NO-UNDO. DEFINE VARIABLE oJsonObject AS JsonObject NO-UNDO. DEFINE VARIABLE oResponse AS JsonAPIResponseCREATE RowErrors. ASSIGN RowErrors.ErrorNumber = 1 RowErrors.ErrorDescription = "Descrição do Erro" RowErrors.ErrorSubType = "ERROR". jsonOutput = JsonAPIResponseBuilder:asError(TEMP-TABLE RowErrors:HANDLE). ... |
Bloco de código | ||
---|---|---|
| ||
... DEFINE OUTPUT PARAM jsonOutput AS JsonObject NO-UNDO. ASSIGN oJsonArray = NEW JsonArray() oJsonObject = NEW JSONObject(). JsonObject(). oJsonObject:Add("ErrorNumber", 1). oJsonObject:Add("ErrorDescription", "Descrição do erro"). oJsonObject:Add("ErrorSubType", "error"). oJsonArray:Add(oJsonObject). jsonOutput = JsonAPIResponseBuilder:asError(oJsonObjectoJsonArray, 403). /* retorna status 403 */ ... |
Bloco de código | ||
---|---|---|
| ||
... DEFINE OUTPUT PARAM jsonOutput AS JsonObject NO-UNDO. DEFINE VARIABLE oJsonObject AS JsonObject NO-UNDO. ASSIGN oJsonObject = NEW JSONObject(). CREATE NO-UNDORowErrors. DEFINE VARIABLE oResponseASSIGN RowErrors.ErrorNumber = 1 AS JsonAPIResponse NO-UNDO. ASSIGN oJsonObject = NEW JSONObject(). RowErrors.ErrorDescription = "Descrição do alerta" RowErrors.ErrorSubType = "warning". jsonOutput = JsonAPIResponseBuilder:asWarning(oJsonObject, TEMP-TABLE RowErrors:HANDLE). /* ou */ jsonOutput = JsonAPIResponseBuilder:asWarning(oJsonObject, 201, TEMP-TABLE RowErrors:HANDLE). /* retorna status 401 */ ... |
Bloco de código | ||
---|---|---|
| ||
... DEFINE OUTPUT PARAM jsonOutput AS JsonObject NO-UNDO. DEFINE VARIABLE oJsonObjectoJsonArray AS JsonObject AS JsonArray NO-UNDO. ASSIGN oJsonArray = NEW JsonArray(). CREATE RowErrors. ASSIGN RowErrors.ErrorNumber = 1 RowErrors.ErrorDescription = "Descrição do alerta" RowErrors.ErrorSubType = "warning". DEFINE VARIABLE oResponse AS JsonAPIResponse jsonOutput = JsonAPIResponseBuilder:asWarning(oJsonArray, FALSE, TEMP-TABLE RowErrors:HANDLE). ... |
Bloco de código | ||
---|---|---|
| ||
... DEFINE OUTPUT PARAM jsonOutput AS JsonObject NO-UNDO. ASSIGN oJsonObjectjsonOutput = NEW JSONObjectJsonAPIResponseBuilder:empty(). /* ou */ jsonOutput = JsonAPIResponseBuilder:empty(500). /* retorna status 500 */ ... |
Nota | ||
---|---|---|
| ||
O retorno dos objetos seguem o padrão conforme o "Guia de implementação de API V2.0". |
Visão Geral
Import HTML Content
Conteúdo das Ferramentas
Tarefas