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 service

Discussion in 'Editor & General Support' started by pauleds2109, Oct 3, 2011.

  1. pauleds2109

    pauleds2109

    Joined:
    Oct 3, 2011
    Posts:
    3
    Hi am trying to get data back from a web service, the script does not have any problem communicating with the service but this is all gets returned in www.text


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
    <HTML><HEAD><TITLE>Bad Request</TITLE>
    <META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
    <BODY><h2>Bad Request</h2>
    <hr><p>HTTP Error 400. The request is badly formed.</p>
    </BODY></HTML>

    I know the web service is working as it has been running for several months now, and if I simply paste the url into a web browser the expected string is returned, but using the exact same url in WWW(url) does not work.

    There does seem to be a lot of people having difficulty using web services with Unity and frankly if we can't get this to work we'll have to give up on Unity and try something else.

    Thanks for any help in advance
     
  2. chabala

    chabala

    Joined:
    Apr 30, 2012
    Posts:
    19
    I am having this same problem. Any information would be amazing.
     
  3. diablo

    diablo

    Joined:
    Jan 3, 2011
    Posts:
    736
    What's the request?
     
  4. chabala

    chabala

    Joined:
    Apr 30, 2012
    Posts:
    19
    I just figured out what my problem was and it may work for you as well. In my URL there was a " " (space) and it didn't like that in the URL sent through curl. If you change the " " to "%20" that works, also you maybe able to make your URL work using the www.escapeURL that unity has. I think it would work if you did something like this:

    url = WWW.escapeURL( url );
    WWW request ( url );
     
  5. diablo

    diablo

    Joined:
    Jan 3, 2011
    Posts:
    736
    Definitely, you need to escape your url. fyi, 20 is the hexadecimal number representing 'space' in the ascii table.