- Home /
Is HttpWebRequest supposed to work in Web Builds or not?
So, I created a little mini-project to test using an HttpWebRequest object to make Facebook Graph calls on each of the Unity target platforms. I did this successfully on the following platforms: Editor, OSX Desktop, Windows Desktop, iOS.
However, I ran into a problem when trying a Web Player build. I got the follow exception when I tired to call HttpWebRequest.Create(). System.NotSupportedException: http://graph.facebook.com/4?fields=cover at System.Net.WebRequest.GetCreator (System.String prefix) [0x00000] in :0 at System.Net.WebRequest.Create (System.Uri requestUri) [0x00000] in :0 at System.Net.WebRequest.Create (System.String requestUriString) [0x00000] in :0 at GraphProof.ExecuteHttpWeb ()[0x00000] in :0
According to Unity Documentation at http://docs.unity3d.com/Documentatio...atibility.html HttpWebRequest should function in the Web Player. Here is a screen capture of the line in question on the MonoCompatibility page: http://s8.postimage.org/yw3tlqitx/Ht...patibility.png.
Is the documentation in error, or could I be doing something wrong (keeping in mind that it worked fine on every other platform I tried).
Update: Also, not looking for anyone to point me to alternatives, I'm aware of things like the WWW class and UniWeb. The targeting of HttpWebRequest is intentional .
Answer by Bunny83 · Jan 10, 2013 at 08:55 PM
The class should work, however some related classes are not supported, so it depends on how you use the webrequest. Also you can't use it to access a third party site due to the SecuritySandbox. The webrequest is of course build on top of .NET sockets. So that would require Facebook to run a crossdomain policy server which they don't run.
I never tried something like that, but this might help.
I have verified that the exact line throwing the "NotSupportedException" is the HttpWebRequest.Create call. Since even creating an instance of the class is not possible it would appear that it is case of it simply not working, at all, rather than not working based on a specific method of use.