Ranjit Soni
Ranjit Soni

Reputation: 614

While creating channel in twilio, how to set CreatedBy property?

I have created channel in Twilio using Java Rest API but there is no setter method of CreatedBy property which is specified at following url.

https://www.twilio.com/docs/api/chat/rest/channels

please suggest a help.

Thanks in Advance

Upvotes: 0

Views: 251

Answers (1)

philnash
philnash

Reputation: 73027

Twilio developer evangelist here.

There is a method to set the channel CreatedBy attribute when using a ChannelCreator. You would use it with the following code:

import com.twilio.Twilio;
import com.twilio.rest.chat.v2.service.Channel;

public class Example {
  public static final String ACCOUNT_SID = "your_account_sid";
  public static final String AUTH_TOKEN = "your_auth_token";

  public static final String SERVICE_SID = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

    Channel channel = Channel.creator(SERVICE_SID)
        .setFriendlyName("MyChannel")
        .setUniqueName("my-channel")
        .setCreatedBy("user-identity")
        .create();

    System.out.println(channel.getAttributes());
  }
}

See the method setCreatedBy in there.

Let me know if that helps at all.

Upvotes: 1

Related Questions