How to send PUT HTTP Request in Flex

2019-01-25 01:16发布

I want to send HTTP PUT Request on one URL to update that content of XML via using API.

URL is like this: https://domainname.com/someurls/id.xml

I want to update that content.

But When I am sending this PUT request, I have seen that in Network Monitor of Flex 4, Its going as the POST request on this web, while I am setting method as PUT in HTTPService variable.

So I am getting error. So is there any way to send the PUT request on the web ? Or Is there any special header to set PUT method ? I have tried method header but its not working....

Please help me.....

3条回答
我只想做你的唯一
2楼-- · 2019-01-25 01:25

While Mitul's response did work for me as well, I was able to get PUT and DELETE requests working by doing the following.

var urlLoader:URLLoader = new URLLoader();
            var urlString:String = "https://www.google.com/arbitraryUrl.json";
            var urlRequest:URLRequest = new URLRequest(urlString);
            urlRequest.method = URLRequestMethod.POST;

            var variables:URLVariables = new URLVariables();
            variables._method = "DELETE";
            urlRequest.data = variables;

            urlLoader.load(urlRequest); 

So same concept really. Different way of going about it. Hope this helps some people.

查看更多
乱世女痞
3楼-- · 2019-01-25 01:38

I have found the solution to send the put and delete service with HTTPSerivce in flex.

You just have to send one more header with the service method POST.

You have to send data in the POST method and attach one more header X-HTTP-Method-Override and the value as the PUT or DELETE.

Your service will be send as PUT or DELETE.

Thanks......

查看更多
该账号已被封号
4楼-- · 2019-01-25 01:44

Flex doesn't support PUT due to the underlying flash player. See this article about the limitations.

There is a workaround here. However, if both the server and the client are under your control, I'd suggest using only GET and POST. Flex just isn't meant for true RESTful clients. (For example make a post with a parameter put=true)

查看更多
登录 后发表回答