Title: Problems with REST API
Last modified: August 31, 2024

---

# Problems with REST API

 *  Resolved [Iudex](https://wordpress.org/support/users/iudex/)
 * (@iudex)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/problems-with-rest-api-2/)
 * I’m having some problems using TranslatePress together with another plugin that
   uses the REST API. The other plugin works just fine for default language (with
   normal links), but since TranslatePress adds the language slug ie. ‘en’ to the
   URL I get “unauthorized” in return. It only works if I am logged in as admin.
   
   Is there a way to turn off force language in links when using REST API? I just
   need my WordPress to use /wp-json/plugin-name/* all the time instead of /en/wp-
   json/plugin-name/*.
    -  This topic was modified 1 year, 9 months ago by [Iudex](https://wordpress.org/support/users/iudex/).
    -  This topic was modified 1 year, 9 months ago by [Iudex](https://wordpress.org/support/users/iudex/).

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

 *  Plugin Author [Cristian Antohe](https://wordpress.org/support/users/sareiodata/)
 * (@sareiodata)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/problems-with-rest-api-2/#post-17989686)
 * Hello,
 * You can exclude the path in TranslatePress -> Settings -> Advanced -> Exclude
   strings -> Do not translate certain paths 
   It should stop TP from translating
   and adding the language parameter in a secondary language.
 * Best Regards
 *  Thread Starter [Iudex](https://wordpress.org/support/users/iudex/)
 * (@iudex)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/problems-with-rest-api-2/#post-17989806)
 * Thanks for the quick reply. I already tried setting all kinds of variations of
   the URL that is used for the REST API namespace without any luck. Even the page
   that calls the REST API. But even if I already added all kinds of variations,
   shouldn’t `/wp-json/*` be enough?
 * Unfortunately neither works. Somehow it seems that it doesn’t apply for API calls.
   I still get an “Unauthorized” error in the console, with the link to the API 
   with the language code in the URL (/en/wp-json/….).
    -  This reply was modified 1 year, 9 months ago by [Iudex](https://wordpress.org/support/users/iudex/).
 *  Plugin Author [Cristian Antohe](https://wordpress.org/support/users/sareiodata/)
 * (@sareiodata)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/problems-with-rest-api-2/#post-17989864)
 * If you need to access the non /en/ version, simply don’t call it. 
   Is the plugin
   that’s trying to access it from your own website? And the error is in the browser
   console? Depending on how the plugin is generating the link to the json api, 
   it might or might not be fixable. Can you please give us a bit more information?
 *  Plugin Author [Cristian Antohe](https://wordpress.org/support/users/sareiodata/)
 * (@sareiodata)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/problems-with-rest-api-2/#post-17989868)
 * For example, on secondary languages, the home_url get filltered in order to receive
   the language parameter. 
   The site_url however does not receive the site URL. 
   So this means you can use site_url to construct a URL without the language parameter.
 *  Thread Starter [Iudex](https://wordpress.org/support/users/iudex/)
 * (@iudex)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/problems-with-rest-api-2/#post-17990496)
 * The plugin is using the get_rest_url() function, and when TranslatePress is used
   this URL is returned with a language code and therefore returning a link that
   doesn’t work.
 *  Thread Starter [Iudex](https://wordpress.org/support/users/iudex/)
 * (@iudex)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/problems-with-rest-api-2/#post-17992876)
 * The error is displayed in the console, yes. I have checked what get_rest_url()
   returns and can confirm that TranslatePress adds the language code as the slug
   in the returned URL. This will make plugins using get_rest_url() unsuable. And
   I find no way to disable it in TranslatePress. Already tried excluding the API
   URLs in TranslatePress, but doesn’t seem to work for that function.
 *  Plugin Author [Cristian Antohe](https://wordpress.org/support/users/sareiodata/)
 * (@sareiodata)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/problems-with-rest-api-2/#post-17993547)
 * Hi, 
   Can you try out this code to remove the lang param from the rest api?
 * /*
   * Remove language from plugin rest api.*/add_filter( ‘trp_home_url’**, **‘
   trp_home_url_no_lang_for_rest_api’**, **10**, **5)**;function trp_home_url_no_lang_for_rest_api(
   $new_url, $abs_home, $TRP_LANGUAGE, $path, $url ){if (str_contains($path, ‘wp-
   json/plugin-name’)){return $url; }
 * return $new_url**;}
    -  This reply was modified 1 year, 9 months ago by [Cristian Antohe](https://wordpress.org/support/users/sareiodata/).
 *  Thread Starter [Iudex](https://wordpress.org/support/users/iudex/)
 * (@iudex)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/problems-with-rest-api-2/#post-18074762)
 * Seems like this is working fine!
 *  Thread Starter [Iudex](https://wordpress.org/support/users/iudex/)
 * (@iudex)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/problems-with-rest-api-2/#post-18099706)
 * [@sareiodata](https://wordpress.org/support/users/sareiodata/) Seems I was a 
   bit too quick in my reply. Not resolved. Same error.
    -  This reply was modified 1 year, 7 months ago by [Iudex](https://wordpress.org/support/users/iudex/).

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

The topic ‘Problems with REST API’ is closed to new replies.

 * ![](https://ps.w.org/translatepress-multilingual/assets/icon.svg?rev=3166541)
 * [TranslatePress - Translate Multilingual sites with AI Translation](https://wordpress.org/plugins/translatepress-multilingual/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/translatepress-multilingual/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/translatepress-multilingual/)
 * [Active Topics](https://wordpress.org/support/plugin/translatepress-multilingual/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/translatepress-multilingual/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/translatepress-multilingual/reviews/)

 * 9 replies
 * 2 participants
 * Last reply from: [Iudex](https://wordpress.org/support/users/iudex/)
 * Last activity: [1 year, 7 months ago](https://wordpress.org/support/topic/problems-with-rest-api-2/#post-18099706)
 * Status: resolved