Title: API: invalid language parameter
Last modified: May 26, 2020

---

# API: invalid language parameter

 *  Resolved [Chris Eilander](https://wordpress.org/support/users/berendbotje/)
 * (@berendbotje)
 * [6 years ago](https://wordpress.org/support/topic/api-invalid-language-parameter/)
 * I have to create translations for existing products, and to save time I decided
   to use the API. The site default language is Dutch, and I try to make English
   translations for over 250 products. When I try to send a translation with
 *     ```
       $newData = [
                 'description' => $description,
                 'short_description' => $shortDescription,
                 'translation_of' => $product->id,
                 'lang' => 'en',
               ];
               $returnTranslationData = $webshop->createProduct($newData);
       ```
   
 * it will return the error
 * > Error: Invalid language parameter: “en” [422]
 * .
 * If I change it to ‘lang’ => ‘nl’, it will succeed. (but not linked to any existing
   product)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [sergey.r](https://wordpress.org/support/users/sergeyr-1/)
 * (@sergeyr-1)
 * [6 years ago](https://wordpress.org/support/topic/api-invalid-language-parameter/#post-12892649)
 * Hello,
    is English active language ( We throw this error when translation language
   not active)?
 * Also can you please show what you have inside `$webshop->createProduct` ?
 * Thanks!
    -  This reply was modified 6 years ago by [sergey.r](https://wordpress.org/support/users/sergeyr-1/).
 *  Thread Starter [Chris Eilander](https://wordpress.org/support/users/berendbotje/)
 * (@berendbotje)
 * [6 years ago](https://wordpress.org/support/topic/api-invalid-language-parameter/#post-12892825)
 * The debug info shows active_languages”:[“en”,”nl”], so they both seem active.
   We already have several pages with english translations, just not the products
   yet.
 * Relevant code would be
 *     ```
       <?php namespace App\Libraries;
       use Automattic\WooCommerce\Client;
   
       /**
        * Class WebshopConnect
        *
        * @package App\Libraries
        */
       class WebshopConnect
       {
           private $woocommerce;
   
           public function __construct(){
             $url = getenv('woocommerce.url');
             $key = getenv('woocommerce.consumer_key');
             $secret = getenv('woocommerce.consumer_secret');
             $this->woocommerce = new Client($url, $key, $secret);
           }
   
           public function createProduct(array $productData){
             return $this->woocommerce->post('products', $productData);
           }
       }
       ```
   
 * [edit]
    Apparently one of my colleagues put the English language on hidden (I
   also didn’t know this was a thing), and this solved it.
 * However, I expected it to be a translation for an existing product when I add
   the translation, but instead it gets added as an new “Dutch” product.
 * > [View post on imgur.com](https://imgur.com/9O2arML)
 * 
    The top one should be a translation of the bottom one, if I understood the 
   documentation here: [https://wpml.org/documentation/related-projects/woocommerce-multilingual/using-wordpress-rest-api-woocommerce-multilingual/](https://wpml.org/documentation/related-projects/woocommerce-multilingual/using-wordpress-rest-api-woocommerce-multilingual/)
    -  This reply was modified 6 years ago by [Chris Eilander](https://wordpress.org/support/users/berendbotje/).
    -  This reply was modified 6 years ago by [Chris Eilander](https://wordpress.org/support/users/berendbotje/).
 *  [sergey.r](https://wordpress.org/support/users/sergeyr-1/)
 * (@sergeyr-1)
 * [6 years ago](https://wordpress.org/support/topic/api-invalid-language-parameter/#post-12893110)
 * You need to put original product id into `'translation_of'` ( in you case ‘Hipertherm…’
   product id ) and `'lang'` to the second language ( in you case ‘en’ )

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘API: invalid language parameter’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce-multilingual/assets/icon-256x256.png?rev=2937122)
 * [WPML Multilingual & Multicurrency for WooCommerce](https://wordpress.org/plugins/woocommerce-multilingual/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-multilingual/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-multilingual/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-multilingual/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-multilingual/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-multilingual/reviews/)

## Tags

 * [api](https://wordpress.org/support/topic-tag/api/)
 * [invalid](https://wordpress.org/support/topic-tag/invalid/)
 * [lang](https://wordpress.org/support/topic-tag/lang/)
 * [language](https://wordpress.org/support/topic-tag/language/)
 * [parameter](https://wordpress.org/support/topic-tag/parameter/)

 * 3 replies
 * 2 participants
 * Last reply from: [sergey.r](https://wordpress.org/support/users/sergeyr-1/)
 * Last activity: [6 years ago](https://wordpress.org/support/topic/api-invalid-language-parameter/#post-12893110)
 * Status: resolved