Search code examples
coldfusioncoldfusion-9

Passing a parameter in CFHTTP URL string


I am using cfhttp to post a series of user supplied parameters to an API. I am passing all of the parameters with <cfhttparam> except one: {myID}. Since the {myID} value will also be supplied by the user, I am wondering how can I make sure it gets passed inside the URL string?

<cfhttp url="http://abc.xyz.com/webservice/{myID}/add/multiple" 
       method="POST" result="returnStruct" >

    <cfhttpparam name="Accept" type="header" value="application/json" />        
    <cfhttpparam type="header" name="datetime" value="#datetime#" />
    <cfhttpparam type="header" name="authorization" value="#authorization#" /> 
    <cfhttpparam type="formfield" name="myAPI" value="1" />
    <cfhttpparam type="formfield" name="param1" value="1000" />
    <cfhttpparam type="formfield" name="param2" value="[email protected]" />
    <cfhttpparam type="formfield" name="param3" value="2" />
    <cfhttpparam type="formfield" name="param4" value="Tester" />
</cfhttp>

Solution

  • The client aplication should have the user's data from a previous request, if you pass it like http://abc.xyz.com/webservice/user_id/add/multiple the server assumes that user_id is the parameter you call {myID}

    Good luck