I’m trying to integrate the sendgrid api for email functionality in progress 4gl and i written piece code , but it’s not working , can anyone help me with fixing these or any suggestions?
DEFINE VARIABLE hHttpRequest AS HANDLE NO-UNDO.
DEFINE VARIABLE hHttpResponse AS HANDLE NO-UNDO.
DEFINE VARIABLE cUrl AS CHARACTER NO-UNDO.
DEFINE VARIABLE cRequestPayload AS LONGCHAR NO-UNDO.
DEFINE VARIABLE cResponse AS LONGCHAR NO-UNDO.
DEFINE VARIABLE cErrorMsg AS CHARACTER NO-UNDO.
cUrl = “https://api.sendgrid.com/v3/mail/send”.
cRequestPayload = ‘{ “personalizations”: [{ “to”: [{ “email”: “[email protected]” }] }], “from”: { “email”: “[email protected]” }, “subject”: “Hello, World!”, “content”: [{ “type”: “text/plain”, “value”: “Heya!” }] }’.
CREATE SERVER hHttpRequest.
hHttpRequest:CONNECT(“-H https://api.sendgrid.com -W Basic -U SG.SEND_GRID_API_KEY -P “).
RUN send-request IN hHttpRequest (
INPUT cUrl,
INPUT “POST”,
INPUT cRequestPayload,
OUTPUT hHttpResponse,
OUTPUT cErrorMsg).
IF VALID-HANDLE(hHttpResponse) THEN DO:
hHttpResponse:GET-BODY(cResponse).
MESSAGE “Response: ” cResponse VIEW-AS ALERT-BOX INFO BUTTONS OK.
DELETE OBJECT hHttpResponse.
END.
IF VALID-HANDLE(hHttpRequest) THEN
DELETE OBJECT hHttpRequest.
Facing the below errors
** “email:” was not found. (293)
** Could not understand line 17. (193)
** “to:” was not found. (293)
** Could not understand line 17. (193)
** “email:” was not found. (293)
** Could not understand line 17. (193)
** “type:” was not found. (293)
** Could not understand line 17. (193)
** “personalizations:” was not found. (293)
** Could not understand line 17. (193)
jahnavi guggilla is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.