Workflow Get header info : X-Total-Count

Hello everyone,
I’m trying to go through a workflow to make a counter on access requests: if the number of people who have the right exceeds 1000: we block.
The trigger is easy, for the count I go through the API call: /v3/search/count. it returns the number of people who have the right via a search:
{“indices”:[“identities”], “query”:{“query”:“@access(id:xxxxxxxxxxxxxxxxxxxxxxxxx)”}}
My problem comes when I retrieve this famous X-Total-Count from my operator: I’ve tried to retrieve it via JSON PATH :


but my workflow with same path doesn’t work. I didn’t even manage to make it “exists” :
image
My payload in the other hand is fine with my JSON Path tests :

I already try other stuff but none seems to work. I also find some people having trouble with this kind of stuff : Response Header count value in Workflow.
PS : I need an int to go with the compare numbers Operator.

Hi @dblanchard,

You can retrieve the X-Total-Count, by doing this :

$.hTTPRequest.headers['X-Total-Count'][0]

Hello @ondiaye , thanks a lot I manage to retrieve it but I still have an issue : it’s a string not a number so the Compare Numbers Operator doesn’t work.

As the results are strings, I tried defining 2 variables for each of my test data, and you can see that they are in the same format, with very similar data: (the 2 verify Data Types are set to “is a string”).

However, the CompareString result doesn’t allow you to do a “less than” despite the fact that the results are very close.

And as I said in my last message, the compare numbers function doesn’t work, I guess, because they’re strings.

Hello everyone, allow me a little UP =)

Hi Dylan,
Why don’t you try $.defineVariable2.X-Total-Count instead of $.defineVariable2[“X-Total-Count”]

Hello @anagha,
yes I already try that on both Operator (Compare String and Compare Numbers). It is the default “Open Variable Selector” who selected both syntax.

Hi @dblanchard,

Can you try this :

$[?( $.defineVariable2["X-Total-Count"]>=$.defineVariable1.countMax )] 

With verify Data type operator with “Exist” options.

In false output ==> that mean your user have less than countMax access
In True output ==> that mean your user have more than countMax access

Hello @ondiaye,
defineVariable are still strings :confused:
The Input is :
“defineVariable1”: { “countMAX”: “10” },
“defineVariable2”: { “X-Total-Count”: “5” },
For this JSONPATH to work, it would have to be INTs and therefore with an input like this :
“defineVariable1”: { “countMAX”: 10 },
“defineVariable2”: { “X-Total-Count”: 5 },
it seems I can’t meet my needs with workflow atm until variable management is simplified.
I create an idea for variables modification : https://ideas.sailpoint.com/ideas/GOV-I-3391

1 Like

Hi @dblanchard,

The strings comparison $[?( $.defineVariable2[“X-Total-Count”]>=$.defineVariable1.countMax )] work.

For example when you evaluate “10” > “5” it return true.

I will vote for your idea :slight_smile:

Best regard

Hi @ondiaye,
maybe my tests are wrong, I did them with the workflow editor and with https://www.javainuse.com/jsonpath
Test 1 : “5” >= “10” give result :


Test 2 : “5” <= “10” no result :

Test 3 : “005” <= “10” give result :

Test 4 : 5 <= 10 give result :

As you can see between test 2 & 4 the values are different depending on the quotation marks and therefore the string demarcation.
Test 3 is strange because I thought the “lesser than” would have calculated the size of the string. But this seems to be another cacul (I couldn’t find the information online)

Thansk a lot !