This overload is deprecated. Use the one with Dictionary argument.

Could someone please help me turn this into a dictionary argument?

using( var www = new WWW( url, bytes, headers ) )
        {
            yield return www;
           
            if( completionHandler != null )
                completionHandler( www );
        }

Turn what into a dictionary argument. Help us, help you.

1 Like

Thanks, starting with line one. Line one is what’s highlighted in unity with this error.

Make your headers variable a Dictionary<string, string> instead of a Hashtable.

There’s also no reason to “using” a WWW. It’ll clean itself up without it.

1 Like

Here is the complete code block.

// Registers the deviceToken with GameThrive. Note that a GameThrive app ID is required to use GameThrive.
    public static IEnumerator registerDeviceWithGameThrive( string gameThriveAppId, string deviceToken, Dictionary<string,string> additionalParameters = null, Action<WWW> completionHandler = null )
    {
        var url = string.Format( "https://gamethrive.com/api/v1/players" );

        var parameters = new Dictionary<string,string>();
        parameters.Add( "device_type", "0" );
        parameters.Add( "app_id", gameThriveAppId );
        parameters.Add( "identifier", deviceToken );
       
        if( additionalParameters != null )
        {
            foreach( var key in additionalParameters.Keys )
                parameters.Add( key, additionalParameters[key] );
        }
       
        var json = Json.encode( parameters );
        var bytes = System.Text.Encoding.UTF8.GetBytes( json );
        var headers = new Hashtable();
        headers.Add( "Content-Type", "application/json" );

        using( var www = new WWW( url, bytes, headers ) )
        {
            yield return www;
           
            if( completionHandler != null )
                completionHandler( www );
        }
    }

Thanks @KelsoMRK . So I should replace

using( var www = new WWW( url, bytes, headers ) )

with

        var www = new Dictionary<string, string>();

?

No. Get rid of Hashtable, replace it with Dictionary. www still needs to be WWW.

–Eric

1 Like

Thanks! I forgot that unity doesn’t always give you the correct one that the error is on. I wasn’t even looking up there.

Unity does always give you the correct line that the error is on, and did so in this case too. The line where you declared a Hashtable was fine; the line where you used in it WWW was not.

–Eric

1 Like

Ok, now I understand, thanks.