Contact form field in wordpress menu

Well, you’re getting error, because your code is not correct… There is syntax error in this line (You combine string and PHP code in there…):

$items .= '<li class="menu-item">echo do_shortcode( '[contact-form-7 id="1323" title="Newsletter"]' );</li>';

It should look like this:

add_filter( 'wp_nav_menu_items', 'your_custom_menu_item', 8, 2 );
function your_custom_menu_item ( $items, $args ) {
    if( $args->theme_location == 'primary')  {
        $items .= '<li class="menu-item">'. do_shortcode( '[contact-form-7 id="1323" title="Newsletter"]' ) .'</li>';
    }
    return $items;
}