401 Unauthorized error when trying to refresh access token

Im trying to set up a php script that will refresh my authorization token:

$url = 'https://api.infusionsoft.com/token/';
$refresh_token = ' ';
$client_id = '  ';
$client_secret = '  ';

$encoded_data = base64_encode($client_id. ":". $client_secret);

$postdata = array(
    'grant_type' => 'refresh_token',
    'refresh_token' => $refresh_token,
);

$options = array(
    'http' => array(
        'header'  => "Content-Type: application/json\r\n" .
                "Accept: application/json".
                "Authorization: Basic ". $encoded_data,
        'method'  => 'POST',
        'content' => json_encode($postdata)
    )
);

All of the credentials are correct, and the refresh token has never been used before, and yet I get a 401 Unauthorized error.

Can you try changing your Content-Type to application/x-www-form-urlencoded?