ballerinaballerina-swan-lake

Compilation fails with gmail connector in Ballerina


gmail:Client gmail = check new ({auth: {token: gmailToken}});
gmail:Message sendMessage = check gmail->sendMessage(messageRequest);

With the above code, I get the following compilation error.

ERROR [main.bal:(30:46,30:57)] undefined method 'sendMessage' in object 'ballerinax/googleapis.gmail:4.0.0:Client'
error: compilation contains errors

Solution

  • ballerinax/googleapis.gmail version 4.0.0 doesn't have sendMessage API.

    Check https://central.ballerina.io/ballerinax/googleapis.gmail/latest.

    I think you can use https://central.ballerina.io/ballerinax/googleapis.gmail/latest#Client-post-users-string-userId-messages-send to send a message as follows.

    Message message = check gmailClient->/users/<userID>/messages/send.post(messageRequest);