Key is present in Dictionary, but error received "The given key was not present in the dictionary"


I have added a key in Config file. When I am trying to retrieve a value corresponding to it in a workflow. I am getting message “The given key was not present in the dictionary”.
I have rechecked and searched the key within the config file , it matches exactly with what is present as a key in the config (dictionary).
Can anyone suggest on it.



Check the argument direction, whether it is In
for debug, you can place a write line outside the workflow and inside the workflow as well and check

Hope this may help you


Actually It is working in some case, and in some case it is not.


Can you explain bit more? what do you mean by some case?


I mean in one of the transaction, at the same point it is identifying the key and getting corresponding value. But in some transaction it is not able to identify the key, although it is there.


Can you check that it is the exact same? also check if there are any whitespaces

Also, it’s better if you provide us with the screenshots


@AnkitJain Try to print the key names in the notepad and see is there is any spaces before or after. Based on this, the further actions can be taken

Can you suggest how can I print key names, I know how to print values :slight_smile:

@AnkitJain YourDictionaryVariable.ElementAt(0).Key

0 is the index of the key. Suppose if you want to get the 3rd key from the dictionary then it should be 2

Also, use Append Line activity to write this data into text file