Azure / azure-sdk-for-java

This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/java/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-java.
MIT License
2.3k stars 1.96k forks source link

ACS Integration issue with JAVA. #21723

Closed skunchakuri closed 3 years ago

skunchakuri commented 3 years ago

Thanks @salujamanish for reply. Yes am using scope as "chat " still facing error. here is my Java Code and Error stack.

/**

import java.time.OffsetDateTime; import java.util.ArrayList; import java.util.Arrays; import java.util.List;

import com.azure.communication.administration.CommunicationIdentityClient; import com.azure.communication.administration.CommunicationIdentityClientBuilder; import com.azure.communication.administration.CommunicationUserToken; import com.azure.communication.chat.ChatClient; import com.azure.communication.chat.ChatClientBuilder; import com.azure.communication.chat.ChatThreadClient; import com.azure.communication.chat.models.ChatThreadMember; import com.azure.communication.chat.models.CreateChatThreadOptions; import com.azure.communication.common.CommunicationUser; import com.azure.communication.common.CommunicationUserCredential; import com.azure.core.http.HttpClient; import com.azure.core.http.netty.NettyAsyncHttpClientBuilder;

/**

}

Error Stack Exception in thread "main" 19:28:42.328 [reactor-http-nio-1] DEBUG reactor.netty.resources.PooledConnectionProvider - [id: 0xe9f2dddd, L:/192.168.0.136:57996 - R:interviewlycs.communication.azure.com/13.107.213.58:443] Releasing channel 19:28:42.328 [reactor-http-nio-1] DEBUG reactor.netty.resources.PooledConnectionProvider - [id: 0xe9f2dddd, L:/192.168.0.136:57996 - R:interviewlycs.communication.azure.com/13.107.213.58:443] Channel cleaned, now 0 active connections and 1 inactive connections com.azure.communication.chat.models.ErrorException: Status code 400, "{"code":"BadRequest","message":"One or more validation errors occurred.","innerErrors":[{"message":"The value provided for Id is invalid.","target":"Members[0].Id"},{"message":"The value provided for Id is invalid.","target":"Members[1].Id"}]}" at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.azure.core.http.rest.RestProxy.instantiateUnexpectedException(RestProxy.java:334) at com.azure.core.http.rest.RestProxy.lambda$ensureExpectedStatus$5(RestProxy.java:375) at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:118) at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1592) at reactor.core.publisher.MonoProcessor.onNext(MonoProcessor.java:317) at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2148) at reactor.core.publisher.MonoProcessor.onSubscribe(MonoProcessor.java:325) at reactor.core.publisher.FluxFlatMap.trySubscribeScalarMap(FluxFlatMap.java:191) at reactor.core.publisher.MonoFlatMap.subscribeOrReturn(MonoFlatMap.java:53) at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:48)

skunchakuri commented 3 years ago

@salujamanish even i tried with Java Script still facing below issue. we have tried will all scopes voip, chat and data is not at all accepting. we have blocked here appreciated quick help!

WhatsApp Image 2021-05-22 at 8 11 44 PM

joshfree commented 3 years ago

@anuchandy could you please help route this

anuchandy commented 3 years ago

Looking at the tutorials it seems API requires a communication identifier to add the participants, example here: https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/communication/azure-communication-chat#chat-thread-operations

But I would let @danielgerlag, @juancamilor confirm.

juancamilor commented 3 years ago

@skunchakuri the members (participants) on the chathread need to be valid users. For instance, try
CommunicationUser user1= communicationIdentityClient.createUser() instead of CommunicationUser user1 = new CommunicationUser("Jhon Kerry")

Also, I recommend you use the GA version of the library. Please let us know if this does not solve your problem. Cheers, Camilo!

FYI @angiurgiu

skunchakuri commented 3 years ago

@juancamilor tried with CommunicationUser user1= communicationIdentityClient.createUser() but its giving different error. can you please look into it!.

Exception in thread "main" com.azure.communication.chat.models.ErrorException: Status code 400, "{ "Code": "BadRequest", "Message": "Initiator is not a participant of the thread", "InnerErrors": [] }"

angiurgiu commented 3 years ago

Hi @skunchakuri, I think the issue is that you are using an old version of the library which requires the thread creator to be among the list of members that you pass in .setMembers(members)

If you use the GA version of the lib, the request initiator should be added for you to the thread without you explicitly adding them to members.

In your case the initiator is this user you create in the beginning:

CommunicationUser identity = communicationIdentityClient.createUser(); System.out.println("\nCreated an identity with ID: " + identity.getId()); ...... CommunicationUserCredential userCredential = new CommunicationUserCredential(userAccessToken);

// Initialize the chat client final ChatClientBuilder builder = new ChatClientBuilder(); builder.endpoint(endpoint) .credential(userCredential) <---- your request initiator, which also needs to be a part of the thread .httpClient(httpClient);