I'm trying to combine a url and string at runtime and then call it.
public static Uri Append(this Uri uri, params string[] paths) { return new Uri(paths.Aggregate(uri.AbsoluteUri, (current, path) => string.Format("{0}/{1}", current.TrimEnd('/'), path.TrimStart('/')))); } var url = new Uri("https://127.0.0.1:2999/liveclientdata/playerscores?summonerName=").Append(_PlayerName).AbsoluteUri; However when I call it, this error is returned:
Failed the request: HTTP/1.1 400 Bad Request The url looks like this
https://127.0.0.1:2999/liveclientdata/playerscores?summonerName=/%22KidKiwi91%22 I know the error is caused by the concatenation of the url and string because it I make it all one url and not combine them in runtime it works.
Other things i've tried:
string url = "urlgoeshere=" + playername; string url = UnityWebRequest.EscapeURL("urlgoeshere" + playername); string url_q = "urlgoeshere=" + playername; var url=new Uri(url_q); It's called using this
private IEnumerator GetJSON(string url, System.Action<string> callback) { failed = false; //Debug.Log(url); using (UnityWebRequest webRequest = UnityWebRequest.Get(url)) { webRequest.certificateHandler = new BypassCertificate(); yield return webRequest.SendWebRequest(); string error = webRequest.error; if (error != null) { Debug.Log("Failed the request: " + error); failed = true; } else { callback?.Invoke(webRequest.downloadHandler.text); //Debug.Log(webRequest.downloadHandler.text); } } } Any ideas?
Thanks
400means that the server was reached correctly but doesn't understand the request ... can you post a URL that is working correctly when you hardcode it and tell us what exactly all your variables hold? I'm pretty sure there is an/too much and it should rather behttps://127.0.0.1:2999/liveclientdata/playerscores?summonerName=%22KidKiwi91%22%22.. how exactly does your_PlayerNamelook like? you could probably avoid it by using_PlayerName.Trim('"')(it is' " 'a bit hard to see ;) )