twilio / twilio-java

A Java library for communicating with the Twilio REST API and generating TwiML.
MIT License
482 stars 421 forks source link

Conversation WebhookCreator Configuration Method always uses POST #728

Closed pc2459 closed 1 year ago

pc2459 commented 1 year ago

Issue Summary

The Webhook.Creator does not respect setConfigurationMethod as the underlying HTTP request builder method addPostParams has the wrong parameter name, resulting in all conversation-scoped webhooks being set to the default POST method. GET methods want love, too!

https://github.com/twilio/twilio-java/blob/main/src/main/java/com/twilio/rest/conversations/v1/conversation/WebhookCreator.java#L119 --> should be Configuration.Method and not ConfigurationMethod

Steps to Reproduce

  1. Create a Conversation Webhook with the WebhookCreator and call setConfigurationMethod with Method.GET
  2. Check the webhook at GET https://conversations.twilio.com/v1/Conversations/CHXXXXXXX/Webhooks and see that the configuration.method is set to the default POST

Code Snippet

Webhook creator:

Webhook.creator(
                "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
                Webhook.Target.WEBHOOK)
            .setConfigurationMethod(Webhook.Method.GET)
            .setConfigurationFilters(
                Arrays.asList("onMessageAdded",
                "onConversationRemoved"))
            .setConfigurationUrl("https://example.com")
            .create();

Incorrect code in generated code: https://github.com/twilio/twilio-java/blob/main/src/main/java/com/twilio/rest/conversations/v1/conversation/WebhookCreator.java#L119 --> should be Configuration.Method and not ConfigurationMethod

        if (configurationMethod != null) {
            request.addPostParam("ConfigurationMethod", configurationMethod.toString());

        }

Exception/Log

N/A

Technical details:

isha689 commented 1 year ago

Hi @pc2459, Thank you for pointing this out. We are looking into this.

pc2459 commented 1 year ago

Incredible speed, thanks!