Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by SweetMei25 · Nov 21, 2018 at 09:14 AM · scripting problemwwwrequest

A problem when putting string variable into request URL

Hello how are you I am going to pass a variable into a URL. But "%E2%80%8B" is attached at the end of the variable.

This is my code.

 [System.Serializable]
     public class Param {
         public string key;
         public string value;
         public Param(string k, string v) {
             key = k;
             value = v;
         }
     }
 
     private string parseParam (List<Param> paramList) {
 
         string strParam = "?";
 
         foreach (Param param in paramList) {
             strParam += param.key;
             strParam += "=";
             strParam += param.value;
             strParam += "&";
         }
 
         return (strParam = strParam.Remove (strParam.Length - 1));
     }
 
 private IEnumerator searchCity() {
         string cityQuery = searchFilter.text;
         string url = "http://geodb-free-service.wirefreethought.com/v1/geo/cities";
         List<Param> paramList = new List<Param> ();
         paramList.Add (new Param ("namePrefix", cityQuery));
         paramList.Add (new Param ("limit", "10"));
         paramList.Add (new Param ("offset", "0"));
         paramList.Add (new Param ("hateoasMode", "false"));
         url += parseParam (paramList);
         UnityWebRequest req = UnityWebRequest.Get(url);
         req.SetRequestHeader ("Content-Type", "application/json;charset=UTF-8");
         yield return req.SendWebRequest ();
         Debug.Log (req.url);
         if (req.error != null) {
             Debug.Log ("Getting Location Data Failed");
         } else {
             Debug.Log (req.downloadHandler.text);
         }
 }

When I put this city name "Liverpool" instead of the variable "cityQuery", the right result shows and at this time, the URL becomes "http://geodb-free-service.wirefreethought.com/v1/geo/cities?namePrefix=Liverpool&limit=10&offset=0&hateoasMode=false" but when I put the variable "cityQuery" then the result becomes "http://geodb-free-service.wirefreethought.com/v1/geo/cities?namePrefix=Liverpool%E2%80%8B&limit=10&offset=0&hateoasMode=false" and so the result not showing.

Any help is appreciated. Please help me with this question. Thanks

Sprietsma

Comment
Add comment · Show 6
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Hellium · Nov 21, 2018 at 09:20 AM 0
Share

Have you checked this link? Did you copy Liverpool from an external source? (formatted text editor, online, ...) If so, type the word Liverpool by hand to avoid extra invisble characters.

avatar image SweetMei25 Hellium · Nov 21, 2018 at 09:47 AM 0
Share

Hello. Thanks for your reply. But the Liverpool string is correct, I checked the output. http://geodb-free-service.wirefreethought.com/v1/geo/cities?namePrefix=Liverpool&limit=10&offset=0&hateoas$$anonymous$$ode=false this works, but string cityQuery = "Liverpool"; "http://geodb-free-service.wirefreethought.com/v1/geo/cities?namePrefix=" + cityQuery + "&limit=10&offset=0&hateoas$$anonymous$$ode=false" this not working I think this is related to geodb-free-service.wirefreethought.com server but not sure and dont know the reason. I would like you to help me. Thanks

avatar image Hellium SweetMei25 · Nov 21, 2018 at 10:05 AM 0
Share

Before building the URL, call Debug.Log( cityQuery + " " + cityQuery.Length ) and make sure the length of the string is correct. As I said, you may have invisible characters causing your issue.

Show more comments
avatar image saschandroid · Nov 21, 2018 at 03:13 PM 0
Share

Perhaps you can just replace the trailing zero-length white space:

  cityQuery.Replace("\u200B", "");


0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

172 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

GET Request dont save data 0 Answers

Unable to upload Image to server with MultipartFormFileSection , WWWForm and Upload Handler 0 Answers

Admob script help 0 Answers

OAuth process 0 Answers

WWW only downloading once? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges