I want to make an API request using lucee/coldfusion.
I setup my token request like this:
cfhttp(
url="[myurl]"
method="POST"
result="token"
) {
cfhttpparam(type="header" name="host" value="[url]");
cfhttpparam(type="body" name="client_id" value="[id]");
cfhttpparam(type="body" name="client_secret" value="[secret]");
cfhttpparam(type="body" name="grant_type" value="[credentials]");
cfhttpparam(type="body" name="scope" value="[url]");
};
But the error message tells me that "grant_type" needs to be included, so it seems like my body here is not sent properly.
Can someone help me out?
Edit:
I also tried this:
var body = {
"host": "[url]",
"client_id": "[id]",
"client_secret": "[secret]",
"grant_type": "[credentials]",
"scope": "[url]"
}
// Token
cfhttp(
url="[url]"
method="POST"
result="token"
) {
cfhttpparam(type="header" name="host" value="[url]");
cfhttpparam(type="body" value="#body.toJson()#");
};