Search code examples
coldfusioncoldfusion-9

Push value to DucksBoard in ColdFusion


I going to implement the DucksBoard API. I made my custom counter on Ducksboard now I want to PUSH value. I read the tutorial I just found this line on DUCKSBOARD to push data

curl -v -u YOUR_API_KEY:unused -d '{"value": 10}' https://push.ducksboard.com/values/235

SO i try something like this in my Coldfusion code

<cfset var1 = '{"value":5}'>  

    <cfhttp url="https://push.ducksboard.com/values/xxxx" method="post" result="httpResp" timeout="60">
        <cfhttpparam type="header" name="Content-Type" value="application/json" />
        <cfhttpparam type="body" value="#serializeJSON(var1)#">
    </cfhttp>

There is less information in the site of Duckboard.Can someone has implemented this.If yes then kindly tell me how to push value and where to use my API key?


Solution

  • I study the API and found the solution You can use this code and change with yours this will work.And don't use serializeJSON in body tag.

    <cfset var1 = '{"value":5}'>  
    
        <cfhttp url="https://push.ducksboard.com/v/xxxx" method="post" username="API-key" password="x"  result="httpResp" >
            <cfhttpparam type="header" name="Content-Type" value="application/json" />
            <cfhttpparam type="body" value='#var1#'>
        </cfhttp>