title: Frontend REST API insert custom post type and assign custom taxonomy
body: <p>I'm using the method from this <a href="https://apppresser.com/wp-api-post-submission/" rel="nofollow noreferrer">tutorial</a> and it works well for creating custom posts (sugestie) in frontend.</p>
  
  <p>The problem is that i can't find a way to assign a custom taxonomy to those posts when the form is submitted. In backend it works well.</p>
  
  <p>This is the taxonomy</p>
  
  <pre><code>register_taxonomy(  
      'cat_sugestie',  //The name of the taxonomy. 
      'sugestie', //post type name
      array(  
          'labels' =&gt; array(
              'name'              =&gt; _x( 'Categorii', 'taxonomy general name', 'books' ),
              'singular_name'     =&gt; _x( 'Categorie', 'taxonomy singular name', 'books' ),
              'search_items'      =&gt; __( 'Cauta Categorii', 'books' ),
              'all_items'         =&gt; __( 'Toate Categoriile', 'books' ),
              'parent_item'       =&gt; __( 'Categorie parinte', 'books' ),
              'parent_item_colon' =&gt; __( 'Categorie parinte:', 'books' ),
              'edit_item'         =&gt; __( 'Editeaza Categorie', 'books' ),
              'update_item'       =&gt; __( 'Update Categorie', 'books' ),
              'add_new_item'      =&gt; __( 'Adauga Categorie', 'books' ),
              'new_item_name'     =&gt; __( 'Numele noii Categorii', 'books' ),
              'menu_name'         =&gt; __( 'Categorii', 'books' ),
          ),  //Display name
          'hierarchical' =&gt; true,  
          'query_var' =&gt; true,
          'show_ui' =&gt; true,
          'show_in_rest' =&gt; true,
          'rest_base' =&gt; 'cat_sugestie',
          'show_admin_column' =&gt; true,
          'rewrite' =&gt; array(
              'slug' =&gt; 'cat_sugestie', // base slug that will display before each term
              'with_front' =&gt; false // display the category base before 
          ),
          'capabilities' =&gt; array(
              'assign_terms' =&gt; 'read',
          )
      )  
  ); 
  </code></pre>
  
  <p>This is how i get the taxonomies in form</p>
  
  <pre><code>&lt;div&gt;
      &lt;label for="post-submission-cat"&gt;
          &lt;?php _e( 'Chose a category', 'your-text-domain' ); ?&gt;
      &lt;/label&gt;
  
      &lt;select name="post-submission-cat" id="post-submission-cat"&gt;
  
      &lt;?php if ($cats = get_terms(array('taxonomy' =&gt; 'cat_sugestie', 'hide_empty' =&gt; false) ) ) {
          foreach ($cats as $cat) { ?&gt;
              &lt;option value="&lt;?php echo $cat-&gt;term_id; ?&gt;"&gt;&lt;?php echo $cat-&gt;name; ?&gt;&lt;/option&gt;
          &lt;?php   
          }
      } ?&gt;
  
      &lt;/select&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>This is the js code for submitting the post</p>
  
  <pre><code>jQuery( document ).ready( function ( $ ) {
      $( '#post-submission-form' ).on( 'submit', function(e) {
          e.preventDefault();
          var title = $( '#post-submission-title' ).val();
          var content = $( '#post-submission-content' ).val();
          var cat = parseInt($('#post-submission-cat' ).val());
  
          var data = {
              title: title,
              content: content,
              post_type: 'sugestie',
              status: 'pending',
              //cat_sugestie: cat  - this doesn't work
          };
  
          $.ajax({
              method: "POST",
              url: POST_SUBMITTER.root + 'wp/v2/sugestie',
              data: data,
              beforeSend: function( xhr ) {
                  xhr.setRequestHeader( 'X-WP-Nonce', POST_SUBMITTER.nonce );
              },
              success : function( response ) {
                  alert( POST_SUBMITTER.success );
              },
              fail : function( response ) {
                  alert( POST_SUBMITTER.failure );
              }
          });
      });
  });
  </code></pre>
  
  <p>So is it possible to achieve this?
  Thank you!</p>