Legacy Dev Forum Posts

 View Only

Sign Up

API Whatsapp Agentless outbound message, message error cannot be in E164 format

  • 1.  API Whatsapp Agentless outbound message, message error cannot be in E164 format

    Posted 06-05-2025 18:06

    Riko80 | 2023-01-02 11:33:27 UTC | #1

    Hi, I need your assistance please because I want to create whatsapp outbound messages I have implemented the whatsapp agentless source code which is in developper tools of Genesys. but when I debug it I get the following error message but I don't know the problem if you can assist me please

    My code source: string basePath = "/api/v2/conversations/messaging/integrations/whatsapp/81ff9d2a-a865-48b2-bb3e-7c4fbe0a14b0";

            PureCloudRegionHosts region = PureCloudRegionHosts.eu_west_1; // Genesys Cloud region
                                                                          
    
    
            PureCloudPlatform.Client.V2.Client.Configuration.Default.ApiClient.setBasePath(region);
            var accessTokenInfo = PureCloudPlatform.Client.V2.Client.Configuration.Default.ApiClient.PostToken("692cf986-2a7d-4df6-9dc7-6bd7a95fff4f", "Eom0X83pVROeFQ9DB1UhZlTPXol7BfIVSVa_ycbTcwY", "https://apps.mypurecloud.ie");
            string accessToken = accessTokenInfo.AccessToken;
            PureCloudPlatform.Client.V2.Client.Configuration.Default.AccessToken = accessToken;
           // var apiInstance = new ConversationsApi();
          //  var body = new SendAgentlessOutboundMessageRequest(); // SendAgentlessOutboundMessageRequest | Create agentless outbound messaging request
    
            try
            {
    
                // Instantiate APIs
                ConversationsApi conversationsApi = new ConversationsApi();
                //var body = new SendAgentlessOutboundMessageRequest(); // SendAgentlessOutboundMessageRequest | Create agentless outbound messaging request
    
                // Build request body
                SendAgentlessOutboundMessageRequest request = new SendAgentlessOutboundMessageRequest();
                request.FromAddress = "+212XXXXXXXXXX";
                request.ToAddress = "+212XXXXXXXXXX";
                request.ToAddressMessengerType = SendAgentlessOutboundMessageRequest.ToAddressMessengerTypeEnum.Whatsapp;
                request.TextBody = "Hello, this is a test notification";
                request.UseExistingActiveConversation = true;
                
                // Call to PostConversationsMessagesAgentless function of Conversations API
                SendAgentlessOutboundMessageResponse response = conversationsApi.PostConversationsMessagesAgentless(request);
    
                // Final Output
                //Console.WriteLine(response.ToString());
                return response.ToString();
            }
            catch (Exception e)
            {
                // Debug.Print("Exception when calling Conversations.PostConversationsMessagesAgentless: " + e.Message);
    
                return "exception" + e.Message;
            }

    when the method SendAgentlessOutboundMessageResponse response = conversationsApi.PostConversationsMessagesAgentless(request); is called the following error message is displayed

    exceptionError calling PostConversationsMessagesAgentless: {"message":"Phone number validation for address, +212XXXXXXXXXX, failed on field, toAddress, with the following error: toAddress on messengerType <whatsapp> cannot be in E164 format","code":"bad.request","status":400,"contextId":"d47b9d91-781d-42ba-a7e4-49e7741942da","details":[],"errors":[]}

    Regards


    tim.smith | 2023-01-03 18:59:16 UTC | #2

    Riko80, post:1, topic:17808
    message":"Phone number validation for address, +212XXXXXXXXXX, failed on field, toAddress, with the following error: toAddress on messengerType cannot be in E164 format

    This should be the to address of the whatsapp account. Only SMS requires E.164 format. You can check the format from an existing message and use that. If an existing conversation is giving you a number that doesn't work here, that sounds like a bug and must be investigated via opening a case with Genesys Cloud Care.


    system | 2023-02-03 18:59:49 UTC | #3

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 17808