showing how rusty i am with CF - in cfscript, insi...
# cfml-general
r
showing how rusty i am with CF - in cfscript, inside a cfhttp { } block, i can't use a for foop to dynamically add cfhttpparam tags - i get an error - just want to make sure that's expected.
p
Go with something like this...
Copy code
httpService = new http();
httpService.setMethod("get");
httpService.setUrl("<http://whatever.com>");

for (i = 1; i <= 5; i++) {
    httpService.addParam(type="url", name="param#i#", value="value#i#");
}

result = httpService.send().getPrefix();


writeOutput(result.fileContent);
j
I would be interested in seeing what error you ran into though, @raymondcamden. Always nice to know what to be on the lookout for.
s
I would have to dig it up but I know I have used a for loop in a cfhttp block. What error are you receiving?
r
it was my understanding that the new http stuff was built before we had 100% tag support in CF, and that it was -very- old. i stopped using them back when i did cf
James - it was a syntax error on the for:
this is what i tried:
Copy code
cfhttp(url="<https://public-api.wordpress.com/wp/v2/sites/richswier.com/posts?_envelope=1>", method="post") {
		cfhttpparam(type="header", name="Authorization", value="Bearer #arguments.token#");
		cfhttpparam(type="header", name="Content-Type", value="application/json");
		for(var key of <http://arguments.post|arguments.post>) {
			cfhttpparam(type="formfield", name=key, value=<http://arguments.post[key]|arguments.post[key]>);

		}
		cfhttpparam(type="file", file=arguments.image,name="media");
	}
j
var key
in
arguments.post
That will likely fix it for you
r
ugh - and i just rewrote it in tags 😛
😎 1
testing
that was it - thank you
j
No problem!
s
@raymondcamden, lol - still rust, just attributed to the wrong code. You coming back to CF?
r
doing a bit of side work for a client. not 'coming back'. that being said, i want to post about cfoauth soon - had a reason to use it for that client and was pleasantly surprised
🙏 1
👍🏻 1
👍 3
m
He lies. He's back guys. Getting a cat-themed CF tattoo next week, right buddy? (<3 you man, don't light saber me bro lol)
😆 1
r
hehehehe