unityWebRequest fails on 2nd run until unity is restarted (870795)

When I run the following code the 1st after I start unity, it works fine and pulls down the expected json into downloadhandler.text.

If I either stop it from running in the editor or set isPlaying to false through the code, then run it a 2nd time without restarting unity, I get the error messages in the 2nd image.

If I restart unity, everything works fine.

In regards to unityWebRequest, is there something that I’m -not- doing correctly? Is there something I need to do when running multiple unityWebRequests? I’ve been googling this for a couple of days now and not seeing what I am doing wrong.

You forgot to add code example and image it seems :slight_smile:

What image though?

void Start()
    {
      
        username= SendData.username;
        webUrl="https://bodytalk.tech/users/"+username+".php";
        UnityWebRequest.ClearCookieCache(webUrl);
        animator = GetComponent<Animator>();
        characterController = GetComponent<CharacterController>();       
        newTargetPoint = waypoints[currentWaypoint].transform.position;
        targetDir = newTargetPoint - transform.position;
        angle = Vector3.SignedAngle(targetDir, transform.forward, Vector3.down);
        Quaternion initialRot = transform.rotation;
        transform.rotation = initialRot * Quaternion.Euler(0, angle, 0);

    }
    IEnumerator GetRequest(string uri)
    {
      
        using (UnityWebRequest webRequest = UnityWebRequest.Get(uri))

        {
           
            // Request and wait for the desired page.
            yield return webRequest.SendWebRequest();

            string[] pages = uri.Split('/');
            int page = pages.Length - 1;

            try{switch (webRequest.result)
            {
                case UnityWebRequest.Result.ConnectionError:
                case UnityWebRequest.Result.DataProcessingError:
                    Debug.LogError(pages[page] + ": Error: " + webRequest.error);
                   
                    break;
                case UnityWebRequest.Result.ProtocolError:
                    Debug.LogError(pages[page] + ": HTTP Error: " + webRequest.error);
                   
                    break;
                case UnityWebRequest.Result.Success:
                    Debug.Log(pages[page] + ":\nReceived: " + webRequest.downloadHandler.text);
                    result = webRequest.downloadHandler.text;
                    result=result.Substring(0,1);
                    Debug.Log("Yeh result hai  "+result);
                    break;
            }}catch(UnityException e){
                print("Can't fetch data");
            }
        }
    }
void Update(){
StartCoroutine(GetRequest(webUrl));
}

Well, you mentioned “I get the error messages in the 2nd image”.

Your code launches a new web request on each update, which is unlikely what you want.
When you exit play mode, all pending requests are automatically aborted and you probably see errors about it.
I don’t know why you say about 2 requests when you should be launching hundreds of them. Maybe you simply got confused due to Unity automatically merging identical console messages and just showing one message with counter of how many times it was logged?