From March 2011

A user just asked:

I need to pass my array to a webserver. But somehow, the array passed with cfhttp throws an error. Please help

You can not pass a structure or an array in a URL as they are complex values and Coldfusion does not have a way to convert them to simple string values (this is what you need to pass in a URL).

The only way to pass complex values is to serialize the Coldfusion struct or array for the URL. Fortunately, Coldfusion has a built in function called “SerializeJSON” to create a simple string. On the other hand, you can convert the simple string back to a struct or array with “DeserializeJSON”.

Here is a simple example how to pass a 2 dimensional array with cfhttp:

[code]]czozNDc6XCI8Y2ZzZXQgbXlhciA9IGFycmF5bmV3KDIpPgo8Y2ZzZXQgbXlhclsxXVsxXSA9IFwia2V5d29yZHNcIj4KPGNmc2V0IG15YXtbJiomXX1yWzFdWzJdID0gXCJSYXp1bmEsIFdvcmRwcmVzcywgVG9tY2F0XCI+CjxjZnNldCBteWFyWzJdWzFdID0gXCJkZXNjcmlwdGlvblwiPgo8Y3tbJiomXX1mc2V0IG15YXJbMl1bMl0gPSBcIlJhenVuYSBpcyBhIGRhbSB3aXRoIGEgbG90IG9mIGZlYXR1cmVzXCI+Cgo8Y2ZzZXQgdGhlanNvbiB7WyYqJl19PSBTZXJpYWxpemVKU09OKG15YXIpPgoKPGNmaHR0cCB1cmw9XCJmdW5jdGlvbi5jZmNcIj4KICAgICAgPGNmaHR0cHBhcmFtIG5hbWU9e1smKiZdfVwianNvbmRhdGFcIiB0eXBlPVwiVVJMXCIgdmFsdWU9XCIjdGhlanNvbiNcIj4KPC9jZmh0dHA+XCI7e1smKiZdfQ==[[/code]

On a Windows machine I came upon the other day (forcefully and not intentional:-) ) I saw that the default engine was “search-results.com”. This URL was called whenever the user entered a keyword in the URL bar (you do know that Google Chrome and Firefox 4 will automatically search for the words you enter in the URL field, don’t you?). Key was, that I wanted to change this URL.

Easy right? Well, as it turned out, it took some small effort to find the right value.

First off, I entered the “about:config” and searched for “browser.search.defaultenginename”. Double clicked on it and changed it to “Google”. Immediately, I restarted Firefox, but unfortunately the search still was being directed to the other site.

Ok, hitting again the “about:config” and this time searching for “search” only revealed that there was another setting called “browser.search.defaultengine” which also pointed to another search engine. Changing it to “Google” also did not help.

Finally, after looking for some more, I find out that the config value “keyword.url” is the one setting that needs to be changed. Low and behold, Firefox even has a nice page on this topic (you just need to know what you need to be looking for, right…).

In short changing the value back to the default value (or any other you want) “http://www.google.com/search?ie=UTF-8&oe=utf-8&q=” fixed it.

Hope this helps.