[Stackoverflow] [Progress OpenEdge ABL] Basic REST GET in Progress OpenEdge

  • Thread starter Thread starter Warley Ferreira Dias
  • Start date Start date
Status
Not open for further replies.
W

Warley Ferreira Dias

Guest
I am suffering to create a single REST GET API in the Progress OpenEdge. Someone have a simple example?

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...
 
Status
Not open for further replies.
Back
Top