1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Stackoverflow]

Discussão em 'StackOverflow' iniciado por fdantas, Setembro 11, 2024.

  1. fdantas

    fdantas Administrator Moderador

    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": "adXX@gmail.com" }] }], "from": { "email": "jaXXX@gmail.com" }, "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)
    ​

    Continue reading...

Compartilhe esta Página