Just wanted to followup on the statement I made about not being able to do
"PUT" and "DELETE" in Flex.
I have found a way to make it happen, just thought I would share.
Instead of using HTTPService, I had to use URLRequest.
The code issues a PUT REST command to the Apigee Usergrid NoSQL system:
It assumes you have a collection(table) named "stores" and you are updating an
entity(record) that has a UUID of "23kdlerj494slmfas-944jfksg"
I now can stop sending my "PUT" and "DELETE" commands through a 3rd party
server,
Jerry
============= sample code ==================
mBuildPutObjects("23kdlerj494slmfas-944jfksg", "theshoestore_23");
public function mBuildPutObjects(vEntityUUID:String, vNewData:String):void{
var vObj:Object = new Object();
vObj.storename = vNewData;
mPutToEntity(vEntityUUID, vObj);
break;
}
public function mPutToEntity(vUUID:String, vObj:Object):void{
var vTempJSONString:String =
com.adobe.serialization.json.JSON.encode(vObj);
var url:String = ('https://api.usergrid.com/'
+ pMyOrgName
+'/'
+ pTheAppName
+ '/stores/'
+ vUUID
+ '?ql=');
var vRequest:URLRequest = new URLRequest(url);
vRequest.method = URLRequestMethod.PUT;
vRequest.contentType = 'application/x-www-form-urlencoded';
vRequest.data = vTempJSONString;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.TEXT;
loader.addEventListener(Event.COMPLETE, mAuthenticated);
loader.addEventListener(IOErrorEvent.IO_ERROR, mIOerrorHandler);
loader.load(vRequest);
//------------------
function mIOerrorHandler(event:Event):void{
trace("mPutToEntity mIOerrorHandler IN RESPONSE ");
}
//------------------
function mAuthenticated(event:Event):void{
var vTempJSON:Object =
com.adobe.serialization.json.JSON.decode(event.currentTarget.data as String,
false);
trace("mPutToEntity mGoodResults vTempJSON.entities[0].name) =
"+vTempJSON.entities[0].name);
}
}
On Aug 8, 2013, at 10:40 AM, OmPrakash Muppirala wrote:
>>
> Have you tried the as3httpclient library? [1]
>
> Thanks,
> Om
>
> [1] https://github.com/gabriel/as3httpclient/blob/master/EXAMPLES.md