I am using ColdFusion 10. I have registered one rest service in ColdFusion Administrator by just adding path to my cfc and service mappings in the rest services tab. I am able to simply GET the data.
Similar to this I wanted a simple example to POST the JSON data but I am having issues doing that. I am using code below and trying to POST the data.
<cfcomponent rest="true" restpath="restService">
<cffunction name="postData" access="remote" returntype="any" produces="application/json" httpmethod="POST">
<cfsavecontent variable="JSONData">
{
"customer": {
"first_name": "Steve",
"last_name": "Lastnameson",
"email": "[email protected]",
"phone": "+15142546011",
"verified_email": true,
"addresses": [
{
"address1": "123 Oak St",
"city": "Ottawa",
"province": "ON",
"phone": "555-1212",
"zip": "123 ABC",
"last_name": "Lastnameson",
"first_name": "Mother",
"country": "CA"
}
]
}
}
</cfsavecontent>
<cfhttp url="http://localhost:8080/rest/restApp/restService" method="post" timeout="300" result="httpResponsePosttest">
<cfhttpparam type="header" name="content-type" value="application/json" />
<cfhttpparam type="header" name="content-length" value="#Len(Trim(JSONData))#" />
<cfhttpparam type="header" name="charset" value="utf-8" />
<cfhttpparam type="body" value="#Trim(JSONData)#" />
</cfhttp>
<cfreturn httpResponsePosttest>
</cffunction>
When I tried to dump httpResponsePosttest I am getting this with blank error message and making it hard to debug. When I tried to hit the same URL in postman with method as POST I am getting "The request has exceeded the allowable time limit tag" as a response.
Can somebody please help me out with this?