I have this code
Example #1
<cffile action = "read" file = "./config.txt" variable = "fileContents">
<cfset line1 = listGetAt(fileContents, 1, chr(10))>
<cfset line2 = listGetAt(fileContents, 2, chr(10))>
<cfset AuthKey = #mid(line1,19)#>
<cfset RefToken = #mid(line2,15)#>
<cfset contentBody = "grant_type=refresh_token&client_id=bcbb1365893&client_secret=62b5a8a84567992666tf986a3f4 74791e&refresh_token=9312beb987fbd8efebf6dc&scope=read%2Bwrite" />
<cfhttp method="POST" url="https://api.wedoo.com/oauth2/access_token">
<cfhttpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded" />
<cfhttpparam type="formfield" name="grant_type" value="refresh_token" />
<cfhttpparam type="formfield" name="client_id" value="bcqq13f2d1d320543524">
<cfhttpparam type="formfield" name="client_secret" value="62b5a8a84567992666tf986a3f474791e" />
<cfhttpparam type="formfield" name="scope" value="read+write" />
<cfhttpparam type="formfield" name="refresh_token" value="#RefToken#" />
</cfhttp>
<cfset cfData = cfhttp.filecontent />
<cfoutput>#cfData#</cfoutput>
When I run this code I get a 500 error. I'm on a Railo server so I don't get any more info.
I can confirm the RefToken value from line 5 is 239hy9uiw784fbew43y7
------------------------------------------------------------------------------------------ -------------------------------------------
----------------------------------------------------------------------------------------------------------------------- --------------
But when I actually put the RefToken value in the code it works fine..like this
Example #2
<cffile action = "read" file = "./config.txt" variable = "fileContents">
<cfset line1 = listGetAt(fileContents, 1, chr(10))>
<cfset line2 = listGetAt(fileContents, 2, chr(10))>
<cfset AuthKey = #mid(line1,19)#>
<cfset RefToken = #mid(line2,15)#>
<cfset RefToken = 239hy9uiw784fbew43y7>
<cfset contentBody = "grant_type=refresh_token&client_id=bcbb1365893&client_secret=62b5a8a84567992666tf986a3f4 74791e&refresh_token=9312beb987fbd8efebf6dc&scope=read%2Bwrite" />
<cfhttp method="POST" url="https://api.wedoo.com/oauth2/access_token">
<cfhttpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded" />
<cfhttpparam type="formfield" name="grant_type" value="refresh_token" />
<cfhttpparam type="formfield" name="client_id" value="bcqq13f2d1d320543524">
<cfhttpparam type="formfield" name="client_secret" value="62b5a8a84567992666tf986a3f474791e" />
<cfhttpparam type="formfield" name="scope" value="read+write" />
<cfhttpparam type="formfield" name="refresh_token" value="239hy9uiw784fbew43y7" />
</cfhttp>
<cfset cfData = cfhttp.filecontent />
<cfoutput>#cfData#</cfoutput>
When I actually put the refresh_token value in the code like in example #2 it works fine.
- Has anyone ever encountered this?
- Do I have a single quote double quote issue?
- Do I need to encode the RefToken value when its inside cfhttp tag?
- Are there other parameters that I could add to the cfhttpparam tag?
- Is there another step I need to take when setting the RefToken value?