开发者

FLEX + AIR + REST - URLRequestMethod.PUT

开发者 https://www.devze.com 2023-02-01 15:56 出处:网络
Can someone show me an example in actionScript to do a POST request? In flashbuilder\'s dataservice it\'s not possible to make a PUT/DELETE :/

Can someone show me an example in actionScript to do a POST request? In flashbuilder's dataservice it's not possible to make a PUT/DELETE :/ Someone got a workaround?

Here's the jQuery Version

var catalogObject = {
'token': 'current_token',
'catalog': 'KAT02',};


$.ajax({
type: "PUT",
url: "/api/json/user/catalog/",
data: $.toJSON(catalogObject),
success: function(data, textStatus) {    
},
dataType: 'json'

});开发者_JAVA技巧

And here my try (generated from flash builder dataservice):

operation = new mx.rpc.http.Operation(null, "switchCatalog");
operation.url = "/api/json/user/catalog/";
operation.method = "PUT";
argsArray = new Array("token","catalog");
operation.argumentNames = argsArray;         
operation.serializationFilter = serializer0;
operation.resultType = Object;    
operations.push(operation);

I try to change the GET to PUT, but the Service recieves a GET


Try using HttpService.

This is how you would do it:

var myHttpService:HttpService = new HttpService();
myHttpService.url ="http://mywebsite.com/full/url/to/the/service";
myHttpService.addEventListener(ResultEvent,callBackFunction);
myHttpService.method= "GET|POST|HEAD|OPTIONS|PUT|TRACE|DELETE";
myHttpService.request = new Object();//with object of name value pairs
myHttpService.send()//this makes the call.

Try this and let us know what happened.

0

精彩评论

暂无评论...
验证码 换一张
取 消