You are giving dictionary where a string or buffer was expected.
You should check your code or debug around the line you get the Exception, check if all the functions that expect a string aren’t getting a dictionary instead.
You probably forgot to index a dictionary.