Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0. #118

Open
yanerobot opened this issue Mar 14, 2024 · 0 comments

Comments

@yanerobot
Copy link

yanerobot commented Mar 14, 2024

Снимок экрана 2024-03-14 205601

I have no idea what this is. Can anyone help?
I didn't change anything in the code. Purely empty project, imported openAI package, added my API key etc., opened sample scene "ChatGPT", pressed "Play" and sent a message. And it happens every single time. So I couldn't get a single request through.
EDIT:
Ok, found out that the problem is with this method:

private async Task<T> DispatchRequest<T>(string path, string method, byte[] payload = null) where T: IResponse
{
    T data;
    
    using (var request = UnityWebRequest.Put(path, payload))
    {
        request.method = method;
        request.SetHeaders(Configuration, ContentType.ApplicationJson);
        
        var asyncOperation = request.SendWebRequest();

        while (!asyncOperation.isDone) await Task.Yield();
        data = JsonConvert.DeserializeObject<T>(request.downloadHandler.text, jsonSerializerSettings);
    }
    
    if (data?.Error != null)
    {
        ApiError error = data.Error;
        Debug.LogError($"Error Message: {error.Message}\nError Type: {error.Type}\n");
    }

    if (data?.Warning != null)
    {
        Debug.LogWarning(data.Warning);
    }
    
    return data;
}

this variable: request.downloadHandler.text
returns a whole html page in a string and not a JSON file

EDIT 2
This is the html page I got:
image
Everything makes sense now since OpenAI doesn't work in Russia. You need a VPN to gain access. I guess, additional check of the response and dedicated error message wouldn't hurt this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant