[SalesForce] sfdx force:mdapi:retrieve giving “UNSUPPORTED_API_VERSION: Invalid Api version specified on URL.”

I'm stumped on this one. I get that the error has to do with an API version mismatch, but as far as I can see everything is on the same version.

I'm trying to pull an unmanaged package from my sandbox using force:mdapi:retrieve, so that I can extract the package.xml file and use it with the new sfdx force:source:retrieve CLI command, which was released in Winter '19.

My Sandbox API is 44.0 (highest selectable version for an Apex class in dev console).

My SFDX Project API is 44.0 ("sourceApiVersion":"44.0" in sfdx-project.json). It's a new project created today expressly to test this.

My VSCode Salesforce Extension Pack is v44.11.0

Here's what I got in my VSCode terminal:

PS P:\SpreadsConsolidation> sfdx force:mdapi:retrieve -p "Spreads Consolidation" -s -u fullcopy -r ./mdpkg

Retrieving source...
ERROR:  UNSUPPORTED_API_VERSION: Invalid Api version specified on URL.

Adding the -a 44.0 flag got the same error.

What am I missing here?

Best Answer

Thanks to sfdcfox and the commenters above for the solution!

in CLI terminal, sfdx force --version and sfdx plugins revealed to me that even if my VSCode extensions are v44, and my CLI version is sfdx-cli/6.44.0-dead729fb5 (windows-x64) node-v8.9.4... well, apparently sfdx itself (which I thought was an abstraction) has a version #, and it was 45.

Solution is to manually override the API version used by your project

After moving into a project folder, specify a version override with the following command:

sfdx force:config:set apiVersion=44.0 This will allow you to use the newer 45.0 features in a LWC project, whilst still being able to work in a 44.0 org without any errors.

Make sure that, if you're playing with an advanced version of the API, that you keep the salesforcedx@pre-release plugin installed until it is upgraded to the latest release.

Related Topic