I am trying to make an authentication request using a connector rule but I get an error when creating my json body. I tried to use the example in the community documentation but I still get an error when using :
I am facing an : Exception occurred in Test Connection. Error: Error executing before operation rule for endpoint ‘Test connection’: BeanShell script error: bsh.ParseException: Parse error at line 57, column 28. Encountered: ( BSF info: BeforeOperationRule at line: 0 column: columnNo
Looks like @atarodia’s suggestion got you a little further. You’re no longer getting a parsing error, but the API endpoint you are hitting is complaining about a bad payload. What does a valid request body for that endpoint look like? How does a valid payload differ from the one you are trying to send?
The payload needs to be on this format :{ "username":"name", "concurrentSession":"false", "password": "pswd" }
I actually got a pretty close result using this code : payload.put("concurrentSession", "false"); payload.put("username", username); payload.put("password", password);
which gave me this payload but I think it is missing the quotation mark
If so, then I think the issue has to do with the concurrentSession property. The doc says it needs to be a boolean, but you are assigning a string to it. Try this code when setting the property:
Map payload = new HashMap();
payload.put("jsonBody","{"username":"$application.username$","password":"$application.password$","concurrentSession":false}");
And I got the same parsing error : Exception occurred in Test Connection. Error: Error executing before operation rule for endpoint ‘Test connection’: BeanShell script error: bsh.ParseException: Parse error at line 70, column 28. Encountered: ( BSF info: BeforeOperationRule at line: 0 column: columnNo
I suggest using the second approach which gives you the 403 error. One thing to note, you don’t need to explicitly set the concurrentSession to false. By default, it will be false, per the API doc. Better to just leave it out.
Are you able to call this API in Postman? I’m curious if you can successfully generate a token manually before trying to call it in this rule.
Yes I ve been able to call this API with Postman and it is successfull. I am using this body for the call { "username":"name", "concurrentSession":"false", "password": "pswd" }
Can you trigger a 403 response when using postman? What did you have to change to get the 403? Is it a bad username or password? This will help us narrow down the cause of the 403 in the rule.
To get a 403 on Postman I had to use a bad username or password. The other changes got me a 404.
Also I am checking the credentials in the log a step ahead and they are in good form.
The credentials might look good before you send the request, but I wonder if the request is encoding them incorrectly. Are you able to log the actual request being sent?
Also, im not sure if this will fix it, but you are capitalizing Username and Password in your jsonBody. Make those lower case like you did in postman.
If the payload looks correct, then I agree, check with CyberArk to see if permissions have changed. Clearly, the rule is able to reach the API, but getting a 403. This usually means the server has received the request but can’t authorize it.