Postman CLI Publish API Error: Unable to find a Git branch connected to this API

I have an API set up with Postman Teams, connected to a GitHub repository. I can publish the API without issues using the Postman desktop app. However, I’m encountering difficulties when trying to publish the API via the Postman CLI.

Here’s what I do:

  1. Clone the GitHub repository to my local machine outside of Postman.
  2. Run the following command at the root folder of the git repo:
postman api publish [api id] --name v1 --release-notes "Demo release notes" --api-definition "C:\Users\x\source\repos\github\x\apis\openapi\index.json"

The command starts with “Fetching contents to publish” but immediately fails and returns

The system cannot find the path specified.

Error: Unable to find a git branch connected to this API. Try running the command again with correct git repository folder or CI pipeline.

Hi Jeremy,

The error you shared above gets raised in 2 scenarios:

  1. If running in a CI pipeline, we are not able to identify the correct branch from Environment variables
  2. If running on a machine manually and we are not able to identify the branch using git cli

So, I just want to verify once:
On the local machine where you are running the postman-cli command, do you have the git cli installed as well?
For example, if you run git --version on the terminal, do you get a valid output?

Sure. I have the repo cloned and git cli running fine in the directory.