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

Hi

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.

Regards

@AnkitJain

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

Thanks

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

@AnkitJain

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

Thanks

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.

@AnkitJain

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

Thanks

@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