1

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.....

Mitul Golakiya
  • 402
  • 4
  • 20

3 Answers3

11

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......

Mitul Golakiya
  • 402
  • 4
  • 20
  • 1
    One should be a little more cautious in using the phrase "the solution". This method depends on the server actually supporting this custom header, which was introduced by Google and MS some years ago (http://code.google.com/apis/gdata/docs/2.0/basics.html#UpdatingEntry). Still, +1, since this is useful in those cases that it is supported (eg, yours ;). – merv Sep 18 '11 at 07:53
  • 1
    Does Amazon S3 support X-HTTP-Method-Override? – jayarjo Aug 14 '12 at 11:24
2

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.

1

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)

Community
  • 1
  • 1
Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
  • +1 not supported. Though I'm pretty sure this is actually a browser limitation, not directly the fault of Flash Player. – Tyler Egeto Sep 04 '10 at 17:05
  • well, I don't know about that. The browser does support PUT. And for example, I think a Java applet can use PUT. – Bozho Sep 04 '10 at 17:09
  • Not all browsers support PUT/DELETE, certainly modern browsers have support for this stuff, but not all older browsers do. Silverlight had the same restriction, at least it the first 2 releases, (I'm not sure about now, I think they may have worked around it.) I'm not familiar with enough Java Applets though. Either way, we will all be far better off when we have proper support for this. – Tyler Egeto Sep 04 '10 at 17:26
  • 2
    well, it is not that hard to implement it after all. HTTP is a simple protocol. – Bozho Sep 04 '10 at 18:07
  • Yah, I have already found that.... I have found on the same site... but thanks for reply...... Thanks you very much.... – Mitul Golakiya Sep 05 '10 at 06:42
  • @Bozho : but then you don’t use the browser stack which prevent sending Javascript cookies. – user2284570 Feb 18 '19 at 22:38