Unity connection to CRX database

I’m trying to create a script that can connect to a pre-existing Adobe CRXDE database but keep hitting issues.

I have tried the following code in a windows forms application and it works perfectly fine, but when try to do the same within Unity is throws a WebException with the internals being:

The remote server returned an error: (503) Service Unavailable. ProtocolError.

The C# code is:

Debug.Log ("Starting");
string postURL = @"http://<address-and-port>/content/claim/newClaim_ab012";
System.Uri uri = new System.Uri(postURL);
HttpWebRequest req = (HttpWebRequest)WebRequest.Create (uri);
ASCIIEncoding enc = new ASCIIEncoding();
NetworkCredential nc = new NetworkCredential("admin", "admin");
req.Method = "POST";
req.Credentials = nc;
req.ContentType = "application/x-www-form-urlencoded";
string dataToSend = @"id=ab012&firstName=test&lastName=test&address=test&middle=test&status=Open&cat=Home&city=test&state=Alive&date=17 October 2013&details=test";
byte[] dataToSendBytes = enc.GetBytes(dataToSend);
req.ContentLength = dataToSendBytes.Length;
using (System.IO.Stream stream = req.GetRequestStream())
	stream.Write (dataToSendBytes, 0, dataToSendBytes.Length);
	HttpWebResponse response = (HttpWebResponse)req.GetResponse();
	string responseString = new System.IO.StreamReader(response.GetResponseStream ()).ReadToEnd ();
	Debug.Log (responseString);
catch (WebException webEx)
	Debug.LogError (webEx.ToString ());
        Debug.LogError(webEx.Status.ToString ());
catch(Exception ex)
	Debug.LogError(ex.ToString ());
Debug.Log ("Ended");

The code sample I used to create the windows forms application can be found here

It should be noted to same web address and format of data was used with the windows form application, so there is no error there. Also the data within the database is the same format, so shouldn’t cause an issue either!

I have solved the issue. It was a problem with my proxy settings.

To allow myself to access the asset store on company machines I had to set up environment variables to allow it to go through the proxy. However, the server we are accessing is in the local network, so using a proxy server interferes with this (basically goes out to external server to try to come back into a private network from an external IP).

Thanks anyway :slight_smile: