tax_input argument for wp_insert_post()

I’m trying to insert custom taxonomies using wp_insert_post() and the tax_input argument, but it doesn’t work. I want to set a post to a custom taxonomy (‘types’) and a category (‘cars’)

$new_post = array(

        'post_title'    =>   $title,

        'post_content'  =>   $description,

        'tax_input' =>   array('types' => array('cars')),  

        'post_status'   =>   'pending',          

        'post_type' =>   'vehicles'  

        );

Solutions Collecting From Web of "tax_input argument for wp_insert_post()"