Cannot get organization webhooks using lucee

OS: Windows 10 (testing locally)
Java Version: 11.0.7
Tomcat Version: 9.0
Lucee Version: 5.3.7.47
Framework: CFWheels 2.2.0

I have been following the github docs to get a list of my organization’s webhooks. I can get them successfully using the commandline:

curl -H "Accept: application/vnd.github.v3+json" -H "Authorization: token %GITHUB_ACCESS%" https://api.github.com/orgs/ORG/hooks

However when I try to use coldfusion to make the request I just get a big fat 404. So hopefully I am just making a simple mistake with cfhttp or something. Here’s my code:

token = server.system.environment.GITHUB_ACCESS;
cfhttp(url="https://api.github.com/orgs/ORG/hooks", method="GET", result="hooksRequest") {
  cfhttpparam(name="accept", type="header", value="Accept: application/vnd.github.v3+json");
  cfhttpparam(name="Authorization", type="header", value="Authorization: token #token#");
}

Any tips are greatly appreciated.

Why are you setting header names and the header variable names also inside the values? Shouldn’t it be like so?

token = server.system.environment.GITHUB_ACCESS;
cfhttp(url="https://api.github.com/orgs/ORG/hooks", method="GET", result="hooksRequest") {
  cfhttpparam(name="Accept", type="header", value="application/vnd.github.v3+json");
  cfhttpparam(name="Authorization", type="header", value="token #token#");
}

To debug: create a cfm template with a simple dump(gethttprequestdata()) and direct your cfhttp to that cfm templates URL and dump the cfhttp content (hooksRequest) to view that data. Compare it with the working curl request (but made with a tool that outputs all request headers and request data (e.g. postman).

1 Like

Thank you! Those fixes and debugging tips helped, now the requests are 200. I don’t have much experience with cfhttp, so for some reason I thought my key:values all go in value and name was some sort of variable declaration.

1 Like