422 error when using npm publish

I’m trying to use the package registry but I’m getting a 422 error back when trying to publish, I may be missing some required field in the package json but the error doesn’t give any help:

0 info it worked if it ends with ok

1 verbose cli [

1 verbose cli ‘C:\Program Files\nodejs\node.exe’,

1 verbose cli ‘C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js’,

1 verbose cli ‘publish’,

1 verbose cli ‘–@foo:registry=https://gitlab.example.com/api/v4/projects/27902131/packages/npm/’

1 verbose cli ]

2 info using npm@6.14.10

3 info using node@v14.15.4

4 verbose npm-session 652877294392b1a0

5 verbose publish [ ‘.’ ]

6 info lifecycle @foo/test@1.0.0~prepublish: @foo/test@1.0.0

7 info lifecycle @foo/test@1.0.0~prepare: @foo/test@1.0.0

8 info lifecycle @foo/test@1.0.0~prepublishOnly: @foo/test@1.0.0

9 info lifecycle @foo/test@1.0.0~prepack: @foo/test@1.0.0

10 info lifecycle @foo/test@1.0.0~postpack: @foo/test@1.0.0

11 notice

12 notice package: @foo/test@1.0.0

13 notice === Tarball Contents ===

14 notice 0 index.js

14 notice 338B package.json

15 notice === Tarball Details ===

16 notice name: @foo/test

16 notice version: 1.0.0

16 notice package size: 349 B

16 notice unpacked size: 338 B

16 notice shasum: cac78d1081ed60cd1e544f6c0d4caed48e1af24a

16 notice integrity: sha512-IOnLwIDjFzFCI[…]I3iuLs0Pmh5pQ==

16 notice total files: 2

17 notice

18 http fetch PUT 422 https://gitlab.com/Tim_tmnz/api/v4/projects/27902131/packages/npm/@foo%2Ftest 597ms

19 verbose stack Error: 422 Unprocessable Entity - PUT https://gitlab.com/Tim_tmnz/api/v4/projects/27902131/packages/npm/@foo%2Ftest

19 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-fetch\check-response.js:117:15

19 verbose stack at processTicksAndRejections (internal/process/task_queues.js:93:5)

20 verbose statusCode 422

21 verbose pkgid @foo/test@1.0.0

22 verbose cwd C:\source\test

23 verbose Windows_NT 10.0.19043

24 verbose argv “C:\Program Files\nodejs\node.exe” “C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js” “publish” “–@foo:registry=https://gitlab.example.com/api/v4/projects/27902131/packages/npm/”

25 verbose node v14.15.4

26 verbose npm v6.14.10

27 error code E422

28 error 422 Unprocessable Entity - PUT https://gitlab.com/Tim_tmnz/api/v4/projects/27902131/packages/npm/@foo%2Ftest

29 verbose exit [ 1, true ]

package.json
{

“name”: “@foo/test”,

“version”: “1.0.0”,

“description”: “”,

“main”: “index.js”,

“scripts”: {

"test": "echo \"Error: no test specified\" && exit 1"

},

“keywords”: ,

“author”: “”,

“license”: “ISC”,

“publishConfig”: {

"@foo:registry":" https://gitlab.com/Tim_tmnz/api/v4/projects/27902131/packages/npm"

}

}

I fixed it - I had the wrong url - should have just been gitlab.com/api
Plus I needed an extra ‘/’ at the end.