Quantcast
Channel: Questions in topic: "webrequest"
Viewing all articles
Browse latest Browse all 387

Web request pulls html script instead of file text!

$
0
0
Having an issue in unity web requests. When I try to download a file from my url if it's not included or if I've updated it online I always get this as a return if I use web client, web request or any variation.> "http://www.w3.org/TR/html4/strict.dtd">>>>MythosWorks>>> border="0"> src="http://98.30.237.126/repo/amb/words.json"> frameborder="0" />>> I just want to return the text form the json file. How would I go about that this is my unity script currently. >> using System.Collections; using System.Collections.Generic; using> System.IO; using System.Net; using> UnityEngine; using> UnityEngine.Networking;>> public class VersionControl :> MonoBehaviour {> // Start is called before the first frame update> void Start()> {> VersionCheck();> }>> // Update is called once per frame> void Update()> {>> }>> // Loading Game Check from dictionary file > version > build!> private void VersionCheck()> {> // Check if file exists!> if (File.Exists(Application.dataPath +> "/Scripts/DB/words.json"))> {> // Set file path & create reader> string path = Application.dataPath +> "/Scripts/DB/words.json";> using (StreamReader dfetch = new StreamReader(path))> {> // fetch data from file and build list, then provide word> count!> string json = dfetch.ReadToEnd();> jsonDataClass jsnData = JsonUtility.FromJson(json);> }> }> // Fetch file form repo!> else> {> WebClient moogle = new WebClient();> moogle.Headers["User-Agent"] => "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36> (KHTML, like Gecko)> Chrome/45.0.2454.85 Safari/537.36";> moogle.DownloadFile("http://www.mythosworks.com/repo/amb/words.json",> Application.dataPath +> "/Scripts/DB/words.json");> Debug.Log("Working on download");> VersionCheck();> }> } Tried without the headers as well. Don't matter if I have to parse the data down, but just really want to download the exact file and save it.

Viewing all articles
Browse latest Browse all 387

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>