Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the library for Whatstapp API version 19 #178

Closed
OldKalash7 opened this issue Apr 17, 2024 · 2 comments
Closed

Using the library for Whatstapp API version 19 #178

OldKalash7 opened this issue Apr 17, 2024 · 2 comments
Labels
question Further information is requested

Comments

@OldKalash7
Copy link

Hello. I'm currently building an application that needs to communicate with whatsapp api. In the meta panel, the version of the api it's 19
image

I'm trying to deserialize the test payload of a message webhook provided by meta, using the WebHook class.

{
  "field": "messages",
  "value": {
    "messaging_product": "whatsapp",
    "metadata": {
      "display_phone_number": "16505551111",
      "phone_number_id": "123456123"
    },
    "contacts": [
      {
        "profile": {
          "name": "test user name"
        },
        "wa_id": "16315551181"
      }
    ],
    "messages": [
      {
        "from": "16315551181",
        "id": "ABGGFlA5Fpa",
        "timestamp": "1504902988",
        "type": "text",
        "text": {
          "body": "this is a text message"
        }
      }
    ]
  }
}

I get the following error:
Unrecognized field "field" (class com.whatsapp.api.domain.webhook.WebHookEvent), not marked as ignorable (2 known properties: "entry", "object"])

I saw the payload you provided in the example: https://github.com/Bindambc/whatsapp-business-java-api/blob/main/src/test/java/com/whatsapp/api/examples/WebHookExample.java

And it's different. This is expected due to the diffent versions (I'ts stated that the library supports 16)? Can the Webhook class be extended somehow to support this new type of payload?

Thanks in advance Mauricio.

Copy link

Hello and welcome! We're glad to see that you've opened your first issue. We appreciate your contribution and would love to hear more about the problem you're experiencing. Our team is actively monitoring this repository and we will do our best to respond to your issue as soon as possible. Thank you for using our project and we look forward to working with you!

@Bindambc
Copy link
Owner

Bindambc commented May 7, 2024

Hello @OldKalash7,

I believe the JSON you posted is incomplete. In the payload, there are the fields 'object' and 'entry.' See the example below, which I also obtained from the v19 API

{
   "object": "whatsapp_business_account",
   "entry": [
      {
         "id": "0",
         "changes": [
            {
               "field": "messages",
               "value": {
                  "messaging_product": "whatsapp",
                  "metadata": {
                     "display_phone_number": "16505551111",
                     "phone_number_id": "123456123"
                  },
                  "contacts": [
                     {
                        "profile": {
                           "name": "test user name"
                        },
                        "wa_id": "16315551181"
                     }
                  ],
                  "messages": [
                     {
                        "from": "16315551181",
                        "id": "ABGGFlA5Fpa",
                        "timestamp": "1504902988",
                        "type": "text",
                        "text": {
                           "body": "this is a text message"
                        }
                     }
                  ]
               }
            }
         ]
      }
   ]
}

@Bindambc Bindambc added the question Further information is requested label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants