Third Light Developer Exchange

Code and templating community forum for developers and software integrators

You are not logged in.

Announcement

If you wish to join the Developer Exchange, please contact your account manager - this is to avoid unnecessary spam in the forums. Many thanks for your understanding.

#1 2021-02-22 15:10:11

NAlmola88
Member
Registered: 2021-02-22
Posts: 4

BAD_INPUT Error message when making a Delete_User callout to Chorus

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

#2 2021-02-22 15:33:37

steve
Third Light Staff
Registered: 2013-06-06
Posts: 105

Re: BAD_INPUT Error message when making a Delete_User callout to Chorus

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

#3 2021-02-23 10:58:58

NAlmola88
Member
Registered: 2021-02-22
Posts: 4

Re: BAD_INPUT Error message when making a Delete_User callout to Chorus

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

#4 2021-02-23 11:42:42

dominic
Third Light Staff
Registered: 2013-06-06
Posts: 119

Re: BAD_INPUT Error message when making a Delete_User callout to Chorus

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

#5 2021-02-23 11:55:25

NAlmola88
Member
Registered: 2021-02-22
Posts: 4

Re: BAD_INPUT Error message when making a Delete_User callout to Chorus

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

#6 2021-02-23 12:18:59

swayampravasahu
Member
Registered: 2021-02-23
Posts: 9

Re: BAD_INPUT Error message when making a Delete_User callout to Chorus

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

#7 2021-02-23 12:23:37

dominic
Third Light Staff
Registered: 2013-06-06
Posts: 119

Re: BAD_INPUT Error message when making a Delete_User callout to Chorus

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

#8 2021-02-23 12:59:29

swayampravasahu
Member
Registered: 2021-02-23
Posts: 9

Re: BAD_INPUT Error message when making a Delete_User callout to Chorus

Hi Dominic,

I have tried with the JSON  with array format and it worked now.

Thanks for the help.

Offline

#9 2021-02-24 12:45:09

swayampravasahu
Member
Registered: 2021-02-23
Posts: 9

Re: BAD_INPUT Error message when making a Delete_User callout to Chorus

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

#10 2021-02-25 06:28:50

swayampravasahu
Member
Registered: 2021-02-23
Posts: 9

Re: BAD_INPUT Error message when making a Delete_User callout to Chorus

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

#11 2021-02-25 10:02:06

swayampravasahu
Member
Registered: 2021-02-23
Posts: 9

Re: BAD_INPUT Error message when making a Delete_User callout to Chorus

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

#12 2021-02-25 19:11:24

dominic
Third Light Staff
Registered: 2013-06-06
Posts: 119

Re: BAD_INPUT Error message when making a Delete_User callout to Chorus

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

#13 2021-02-26 08:42:00

swayampravasahu
Member
Registered: 2021-02-23
Posts: 9

Re: BAD_INPUT Error message when making a Delete_User callout to Chorus

Thanks Dominic,

Let me try this option.

Offline

#14 2021-02-26 12:49:06

swayampravasahu
Member
Registered: 2021-02-23
Posts: 9

Re: BAD_INPUT Error message when making a Delete_User callout to Chorus

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

#15 2021-03-02 10:44:07

NAlmola88
Member
Registered: 2021-02-22
Posts: 4

Re: BAD_INPUT Error message when making a Delete_User callout to Chorus

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

#16 2021-03-02 15:13:32

swayampravasahu
Member
Registered: 2021-02-23
Posts: 9

Re: BAD_INPUT Error message when making a Delete_User callout to Chorus

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

#17 2021-03-11 17:12:57

dominic
Third Light Staff
Registered: 2013-06-06
Posts: 119

Re: BAD_INPUT Error message when making a Delete_User callout to Chorus

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

#18 2021-03-15 08:22:25

swayampravasahu
Member
Registered: 2021-02-23
Posts: 9

Re: BAD_INPUT Error message when making a Delete_User callout to Chorus

Hi Dominic,

Thanks for your response.

Offline

Board footer