Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Web Request Error w/ Web API

Discussion in 'Editor & General Support' started by Sessional, Mar 4, 2015.

  1. Sessional

    Sessional

    Joined:
    Apr 21, 2013
    Posts:
    45
    I have just updated to Unity5 as it showed up and I wanted to see the WebGL stuff. The load times were absurd and the amount of memory required to run it was almost double the required for the web player, so I have opted to just let it be for now and continue with my project using web player.

    The problem I am having with web player is that in some browsers (IExplorer and Firefox) the web requests are being replied to with a 415 error from my WebAPI server. The same code (as far as I am aware?) works in the Unity editor and Chrome and Opera.

    Opening up Fiddler I looked at the body of the request being sent to the server through Firefox, and it has additional content in the body:
    Code (csharp):
    1.  
    2. Content-Length: 102
    3. Content-Type: application/json; charset=utf-8
    4. X-Unity-Version: 5.0.0f4
    5.  
    6. {"Username":"testaccountusername","Password":"asha256password"}
    7.  
    The response given by the server is:
    Code (csharp):
    1.  
    2. {"Message":"The request contains an entity body but no Content-Type header. The inferred media type 'application/octet-stream' is not supported for this resource.","ExceptionMessage":"No MediaTypeFormatter is available to read an object of type 'LoginRequest' from content with media type 'application/octet-stream'.","ExceptionType":"System.Net.Http.UnsupportedMediaTypeException","StackTrace":"  at System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent content, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)\r\n  at System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)"}
    3.  
    This is ONLY occurring in Firefox (and possibly IExplorer).

    The segment of code in question from my webserver has the following signature:
    Code (csharp):
    1.  
    2. [Route("api/login")]
    3. public IHttpActionResult PostLogin([FromBody] LoginRequest request)
    4.  
    Any suggestions for resolving or working around it?
     
  2. mhasanac

    mhasanac

    Joined:
    Jul 21, 2014
    Posts:
    6
    We have same issue and while investigating in Firefox another Content-lenght header is being sent. In unity 4 everything works ok with this scenario.

    Code (CSharp):
    1. Content-length: 166
    2.  
    3. Content-Length: 89
    4. Content-Type: application/json
    5. X-Unity-Version: 5.0.0f4
    6.  
    7. {"app_id":"53e3231ecc84c000185","login":"user@user.com","password":"somepassword"}
     
  3. mhasanac

    mhasanac

    Joined:
    Jul 21, 2014
    Posts:
    6
    Last edited: Mar 4, 2015
  4. Good-old-Grim

    Good-old-Grim

    Joined:
    Jan 17, 2014
    Posts:
    33
    Wow, I completely misread the original post. Sorry. Disregard it.
     
  5. mhasanac

    mhasanac

    Joined:
    Jul 21, 2014
    Posts:
    6
    Can someone from the Unity 5 team reply to this thread? Or should we report a bug through Unity 5 ?
     
  6. david_n

    david_n

    Joined:
    Feb 12, 2015
    Posts:
    3
    Same issue here with Webplayer and Firefox on OSX Yosemite. It works just fine with Safari and Chrome.
     
  7. lami

    lami

    Joined:
    Jun 17, 2013
    Posts:
    17
  8. david_n

    david_n

    Joined:
    Feb 12, 2015
    Posts:
    3
    Any news on this issue? It's been more than two weeks now, and we are really stuck with it.
     
  9. notprathap

    notprathap

    Joined:
    Jan 18, 2013
    Posts:
    9
    Bump. Same issue.
     
  10. lami

    lami

    Joined:
    Jun 17, 2013
    Posts:
    17
    Fix should be included in yesterdays patch Unity5.0.1p1 but unfortunately its not possible to release a game for webplayer with a patch release:
    Please be aware that you cannot build and release a Web Player game with a patch release, as the runtime will not be updated with patch versions.
    http://unity3d.com/unity/qa/patch-releases
    Seems like we have to wait for the official release...
     
  11. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,067
    Yes, unfortunately you have to wait for the next proper release 5.0.2f1
     
  12. cojo71

    cojo71

    Joined:
    Aug 19, 2014
    Posts:
    26
    Is there an ETA on when this will be? It's really, really affecting our business to not be able to launch on Unity 5 with a web player build because your release cycle won't fix critical show-stopper bugs in a timely fashion.
     
    Last edited: Apr 22, 2015
    Kronnect likes this.