Skip to main content
Version: 3.0.0

Return Methods

There multiple return method, will helps you to determine your request.

 var res = await whatsapp.sendMessage(
phoneNumber: '+91XXXXXXXXXX',
text: "Hello, this is a test message!"
);

isSuccess() bool

Check if the request was successful. Returns true if the HTTP status code is between 200 => and < 300.

Example
res.isSuccess();
// true

getHttpCode() int

Get the HTTP status code.

Example
res.getHttpCode();
// 200

getError() String

Get HTTP Request error message.

Example
res.getError();
// An error occurred: ClientException: Failed to parse header value

getErrorMessage() String

Get exact error message from whatsapp business api.

Example
res.getErrorMessage();
// The phone_number parameter is required.

getMessageId() String

Get sent message whatsapp message id.

Example
res.getMessageId();
// wamid.HBgMOTE3MDIzMDQyMzA2FQIAERgSMDlCNTVGMUJFMkMxOTU1RUJEAA==

getPhoneNumber() String

Get the phone number where message has been sent.

Example
res.getPhoneNumber();
// +91XXXXXXXXXX

getResponse() Map

Get response body from request.

Example
res.getResponse();
// {
// messaging_product: whatsapp,
// contacts: [{
// input: +91XXXXXXXXXX,
// wa_id: 91XXXXXXXXXX
// }],
// messages: [{
// id: wamid.HBgMOTE3MDIzMDQyMzA2FQIAERgSRkVCRTM5Q0UwQUIyOTE4NTEzAA==
// }]
// }

getMediaId() String

Get media id of uploaded media after upload.

Example
res.getMediaId();
// 1041224066853401

getMediaUrl() String

Get public media url of uploaded media.

Example
res.getMediaUrl();
// https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=1041224066853401&ext=1721591487&hash=ATv7_iq0Tnoi1nO4eh06M7qF-fSHGa-QExcJEnkpOaCYOA

getMediaMimeType() String

Get Uploaded media MIME type.

Example
res.getMediaMimeType();
// image/png

getMediaSha256() String

Get Uploaded media SHA-256 hash.

Example
res.getMediaSha256();
// 4d2e172311d776ff44ff03ec1fdd86e05bb6c2fbc8c9a0595e48fd7cbacba6ba

getMediaFileSize() String

Get media file size in bytes

Example
res.getMediaFileSize();
// 187604