Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Parse Json from Url [Closed]

Discussion in 'Multiplayer' started by thethanksforthegod, Oct 23, 2022.

  1. thethanksforthegod

    thethanksforthegod

    Joined:
    Feb 18, 2020
    Posts:
    19
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,533
    Which ways?
    How does it fail?
    Code snippets?
     
  3. thethanksforthegod

    thethanksforthegod

    Joined:
    Feb 18, 2020
    Posts:
    19
    Thanks for your fast reply
    Code (CSharp):
    1. async void Start()
    2.     {
    3.         ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls13;
    4.         ServicePointManager
    5.     .ServerCertificateValidationCallback +=
    6.     (sender, cert, chain, sslPolicyErrors) => true;
    7.         //StartCoroutine(GetText());
    8.  
    9.         using (WebClient wc = new WebClient())
    10.         {
    11.             var json = wc.DownloadString("https://api.wenlambo.one/meta?meta=1514");
    12.  
    13.         }
    14.  
    15.         using (var httpClient = new HttpClient())
    16.         {
    17.             ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls13 | SecurityProtocolType.Tls12;
    18.             ServicePointManager
    19.         .ServerCertificateValidationCallback +=
    20.         (sender, cert, chain, sslPolicyErrors) => true;
    21.             var json = await httpClient.GetStringAsync("http://api.wenlambo.one/meta");
    22.             Debug.Log(json);
    23.             // Now parse with JSON.Net
    24.         }
    25.     }
     
  4. Max_Bol

    Max_Bol

    Joined:
    May 12, 2014
    Posts:
    168
    Out of curiosity, are you sure http://api.wenlambo.one/meta or api.wenlambo.one/meta?meta=1514 can be remotely accessed at all without a specific api? You're basically trying to access it like if it was a regular http access (like a public web page) which mean we should be able to open it directly in a browser, but trying it returns 502 Bad Gateway which means it's not publicly available, if available at all.
     
    thethanksforthegod likes this.
  5. thethanksforthegod

    thethanksforthegod

    Joined:
    Feb 18, 2020
    Posts:
    19
    thanks the problem solved as it was using TLS 1.3 which isn't supported in unity yet