lokalise / node-lokalise-api

Lokalise API v2 Node.js client.

Home Page:https://lokalise.github.io/node-lokalise-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Project with branches" apis supports

oyzhen opened this issue · comments

commented

It seems "Project with branches" apis not supported in this repo.

Of course it is supported https://lokalise.github.io/node-lokalise-api/api/getting-started#branching

If you are using project branching feature, please add the branch name separated by semicolon to your project ID in any endpoint to access the branch. For example, in order to access new-feature branch for the project with an id 123abcdef.01:

lokaliseApi.files().list({project_id: '123abcdef.01:new-feature'});

Hello @bodrovis, before I create a new issue, it seems that this behaviour is broken. Now I get this error:

{ message: 'Invalid `project_id` parameter', code: 400 }

And it works when I remove the branch name and the semicolon. Has anything changed recently?

@aoumiri nope, I don't think so. Could you please share your code?

I've just checked with the most recent version, it works fine:

(async function () {
  const LokaliseApi = await (import('@lokalise/node-api').then(m => m.LokaliseApi));
  const lokaliseApi = new LokaliseApi({ apiKey: "secret"});

  console.log(await lokaliseApi.keys().list({project_id: "2273827860c1e2473eb195.11207948:develop"}));
})();

Please double-check your project ID and the branch name. Also please be aware that certain endpoints do not support branching (full list can be found here under "Projects with branches" https://developers.lokalise.com/reference/lokalise-rest-api)

Sure 👍

It's a code that has been working for more than 6 months, to download files:

  let lokaliseApi = new LokaliseApi({ apiKey });

  let { bundle_url } = await lokaliseApi
    .files()
    .download(`${projectId}:${branchName}`, {
      export_empty_as: 'empty',
      format: 'json',
      include_tags: tags,
      json_unescaped_slashes: true,
      plural_format: 'icu',
      replace_breaks: false,
    })

On that code, when I remove the branchName, and just pass the projectId, it works fine, but it's on master branch by default. We noticed that it was not working anymore today, and we get the 400 error as if the API didn't split the branch name from the projectId anymore.

Wait, I just retried, it seems to be fixed now. Probably a temporary issue on the API? Thanks for answering!

I'm not entirely sure (we haven't received any reports) but if this issue keeps reapperaing please report it directly to the support team via the chat widget at lokalise.com 👍 Hopefully, it was a small hiccup!