Hello all,
I'm new here and I have a lot of fun developing with Unity, however I can't find a satisfying solution to my problem. I'm working on an iPhone app that has to send a `HTTP PUT` request to a REST server at some point.
The first thing I did was to look at Unity's `WWW` and `WWWForm` classes, however they support `GET` and `POST` only.
So I decided to use .Net 2.0's `HttpWebRequest` instead. I built my project with the full .Net 2.0 compatibility level (I used the subset until now), but I got the following error:
Uri putUri = new Uri("http://myserver.com/path");
HttpWebRequest request = WebRequest.Create(putUri) as HttpWebRequest;
That code works in Unity when I press play, but on the iPhone it throws:
MissingMethodException: Method not found: 'Default constructor not found...ctor() of System.Configuration.ExeConfigurationHost'. at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in :0 at System.Activator.CreateInstance (System.Type type) [0x00000] in :0 at System.Configuration.InternalConfigurationSystem.Init (System.Type typeConfigHost, System.Object[] hostInitParams) [0x00000] in :0 at System.Configuration.InternalConfigurationFactory.Create (System.Type typeConfigHost, System.Object[] hostInitConfigurationParams) [0x00000] in :0 at System.Configuration.ConfigurationManager.OpenExeConfigurationInternal (ConfigurationUserLevel userLevel, System.Reflection.Assembly calling_assembly, System.String exePath) [0x00000] in :0 at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x00000] in :0 Rethrow as ConfigurationErrorsException: Error Initializing the configuration system. at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x00000] in :0 at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00000] in :0 at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00000] in :0 at System.Net.WebRequest..cctor () [0x00000] in :0 Rethrow as TypeInitializationException: An exception was thrown by the type initializer for System.Net.WebRequest at REST.MakePutRequest (System.String data) [0x00027] in /Users/Antho/Unity Project/Assets/Scripts/Network/REST.cs:68
I originally thought the problem originated in using a string in `WebRequest.Create()`, but changing to an URI object didn't help. I tried to remove the `HttpWebRequest` casting and use WebRequest objects instead, it didn't help.
My `REST.cs` file contains other functions for `GET`, `POST` and `DELETE` methods and they also work in Unity and break in the iPhone app.
The last ditch solution would be to call an external function that's hooked to the HTTP framework in Objective-C, but I don't want to do that before I make sure I cannot use `HttpWebRequest`/`WebRequest` in Unity for iOS.
Thanks!
Antho
Related questions:
http://answers.unity3d.com/questions/37162/webrequest-create-problem http://answers.unity3d.com/questions/55176/www-put-method