You are not logged in.
We are attempting to integrate our instance of Salesforce with Chorus.
Our developer has completed a callout to delete a User in Chorus but is receiving a BAD_INPUT error.
Here is the original request sent from Salesforce to Chorus in JSON (message sent from our developer):
--------------------------------------------------------------------------------------------------------------------------------------------------------------
String userCheckJson='{ "apiVersion":"2.0","sessionId":"'sessionId'","action":"Users.DeleteUser","inParams":{"userRef":"'userIdList'" }} ';
On this delete user call i am getting Bad input.
String userId=findUser(sessionId,email);
List<String> userIdList= new List<String>();
if(userId !=null)
{ userIdList.add(userId); }
Here userIdList contains the output value of Users.FindUsers.
String userCheckJson='{ "apiVersion":"2.0","sessionId":"'sessionId'","action":"Users.FindUser","inParams":{"userRef":"'email'" }} ';
Basically I am getting the output from Findusers as : 64943
Adding this string to a list of string and then sending this to deleteUsers.
-------------------------------------------------------------------------------------------------------------------------------------------------------------
We are sending through the UserId which we obtain through the Users_FindUser method.
We have attempted using both Integer and String data types to pass the UserId.
When we look at the API schema, it stipulates we need 'Required Rights: delete'.
Please can you confirm firstly that we are accessing the correct method and secondly how we obtain the required rights (including input parameters) to perform the deletion.
Offline
Hi,
Could you try changing the InParams section for Users.DeleteUser to look like this:
"inParams":{"userId":"64943"}
The current use of "userRef" instead of "userId" could be the problem here.
Regarding required rights, the API allows you to impersonate a specific user account with Core_ImpersonateUser. If you are using that, please login to the normal Chorus web interface to check if the user account you are impersonating is able to perform the delete action upon a user.
Best Regards,
Steve
Offline
Hi there,
Thank you for your response.
Is there anyway to add our developer onto this ticket for visibility?
That would help greatly with expediting the closure of this requirement.
Our developer has updated the code but we are now receiving a new error, please see below:
----------------------------------------------------------------------------------------------------------------------------------------------
For find user I am using the below JSON :
'{ "apiVersion":"2.0","sessionId":"'sessionId'","action":"Users.FindUser","inParams":{"userRef":"'email'" }} '
As a output of Finduser, we are getting :--
{"result":
{"api":"OK","statusCode":0,"action":"OK"}
,"sideLoad":[],"outParams":"64943","sessionTrackingId":"95f14dab-40d9-4f30-b004-0756a6ea19c2"}
Addind this 64943 to the List of strings and sending to deleteUser with the below JSON :
'{ "apiVersion":"2.0","sessionId":"'sessionId'","action":"Users.DeleteUser","inParams":{"userId":"'userIdList'" }} '
The output of deleteUser :--
{"result":
{"api":"OK","action":"USER_NOT_FOUND","statusCode":5}
,"sessionTrackingId":"95f14dab-40d9-4f30-b004-0756a6ea19c2","correlationId":"1f237da3-ce36-4870-b2d9-d9c95129a2ac"}
------------------------------------------------------------------------------------------------------------------------------------------------------------------
Is there anyway to check the UserId on the UI in Chorus for manual verification?
Finally we have a call tomorrow at 9.30 with our developer, is anyone from Thirdlight available for this call?
Appreciate this is an early time but our developer is based in India.
Offline
Hi,
Could you post the inParams as sent? To delete multiple users, it should be an array, as follows:
"inParams":{"userId":["64943","123456"]}
whereas it looks from your code snippet that you are sending a single string (which would certainly explain the error)
Offline
Hi Dominic,
I am waiting for our developer to respond. Are we able to take this exchange off the forum and onto email?
I can see that there is an email option next to your profile detail and would like to include the developer on this exchange.
Offline
Hi Dominic,
This Swayamprava, (Salesforce developer). Thanks for your quick response.
Please check the below code, Where I am sending a list of userIds. Currently I need to delete only 1 record. So I have added the userId to the UserIdList and sending this list in JSON in deleteUser method.
Adding this 64943 to the List of strings and sending to deleteUser with the below JSON :
'{ "apiVersion":"2.0","sessionId":"'sessionId'","action":"Users.DeleteUser","inParams":{"userId":"'userIdList'" }} '
The output of deleteUser :--
{"result":
{"api":"OK","action":"USER_NOT_FOUND","statusCode":5}
,"sessionTrackingId":"95f14dab-40d9-4f30-b004-0756a6ea19c2","correlationId":"1f237da3-ce36-4870-b2d9-d9c95129a2ac"}
Please let me know where I am missing the part.
Offline
Hi,
Per my previous message, please post the actual inParams as sent.
The JSON above makes it look like you are sending the list as a single string, which would be incorrect. It should be a JSON array, like my example.
Dominic
Offline
Hi Dominic,
I have tried with the JSON with array format and it worked now.
Thanks for the help.
Offline
Hi Dominic,
Today I tried to send multiple email address with comma separated. From the code I can see the Users.FindUser method is accepting only one variable, is there any way i can send multiple data and get all user's IDs.
Offline
Hi Dominic,
Today I tried to send multiple email address with comma separated. From the code I can see the Users.FindUser method is accepting only one variable, is there any way i can send multiple data and get all user's IDs.
Offline
Hi,
In salesforce code before calling to chorus we are forming the email string and passing to callout. Below is the code:
Forming the email:
-----------------------
if(contactListToConsider.size()>0){
String conEmail='';
for(Contact con : contactListToConsider){
if(con.Email!=null){
if(sizeOfList<contactToConsider.size()){
conEmail=conEmail+con.Email+',';
}
}
}
//Do the callout here
chorusCallOut.findAndDeleteUser(conEmail);
}
Code where we calling chorus system-----
'{ "apiVersion":"2.0","sessionId":"'+sessionId+'","action":"Users.FindUser","inParams":{"userRef":"'+conEmail+'"}}';
Please le me know if we can pass multiple emails and get all the user ids. As I can see in FindUser it is accepting a single email.
Offline
Hi,
You cannot pass multiple to FindUser. The easiest thing would be to do it inside the loop over contacts.
One possible alternative option would be to call Users.GetAllUsers and then intersect it with your list from Salesforce locally.
(You can supply a single text filter to GetAllUsers based on a CONTAINS match against name, description and email, so if the users you are looking for have something in common, that may help to reduce the return payload).
Dominic
Offline
Thanks Dominic,
Let me try this option.
Offline
Hi Dominic,
I am able to get all the details, But not able to add single text filter, Can you please share the JSON for that input?
Offline
Hi Dominic,
We have been able to successfully call the Users.GetAllUsers method and isolate the Users in the array.
However we are still unable to reduce the payload size which will cause us to quickly hit governor limits on the Salesforce side.
Are you able to provide an example JSON script where we can use the single text filter in this?
Appreciate the assistance
Offline
Hi Dominic,
I am passing the below JSON with filter.
{ "apiVersion":"2.0","sessionId":"'+sessionId+'","action":"Users.GetAllUsers","inParams":{"nameFilter":["newtest2@abc.com","newtest3@abc.com"]}}
Getting the output as below. Please let me what is wrong here, as it is not saying a bad input.
{"result":{"api":"INTERNAL_ERROR","action":"API_ERROR","statusCode":13},"sessionTrackingId":"94bd0333-9a81-4cf9-b1fc-0140c2b73c5a","correlationId":"7e5eeb9e-9566-4e25-a6a1-15df3f250898"}
Offline
Hi,
As I said previously, you can only pass a single nameFilter - in your example, you could use "newtest", which would match both of them, (Alternatively, @abc.com).
Dominic
Offline
Hi Dominic,
Thanks for your response.
Offline