W
Warley Ferreira Dias
Guest
I am suffering to create a single REST GET API in the Progress OpenEdge. Someone have a simple example?
Continue reading...
Code:
DEFINE VARIABLE cResponse AS LONGCHAR NO-UNDO.
DEFINE VARIABLE cJson AS LONGCHAR NO-UNDO.
DEFINE VARIABLE cJsonConverted AS CHARACTER NO-UNDO.
DEFINE BUFFER bCustomer FOR Customer.
cJson = "[".
FOR EACH bCustomer NO-LOCK:
cJson = cJson + "{" +
'"CustNum": "' + STRING(bCustomer.CustNum) + '", ' +
'"Name": "' + bCustomer.Name + '", ' +
'"City": "' + bCustomer.City + '", ' +
'"Country": "' + bCustomer.Country + '"' +
"}, ".
END.
cJson = TRIM(cJson, ", ") + "]".
/* Converte LONGCHAR para CHARACTER antes de enviar a resposta */
cJsonConverted = STRING(cJson).
/* Define o cabeçalho da resposta REST */
OUTPUT CONTENT-TYPE "application/json".
PUT UNFORMATTED cJsonConverted.
Continue reading...