I'm having an issue with using the Artifactory REST API to create virtual repositories that I've struggled with the last couple days. No issues with local or remote repositories. I am able to get the Virtual repository created using only the required JSON entries, but I would like to add more to that. I want to store the JSON for future reference so we can refer back to it if we ever wish to create other virtual repositories (as a template of sorts).
I'm doing this with PowerShell. I'm passing a list of repository names. The Script parses the repository name and collects an appropriate config file containing the JSON values.
Create repository API info: https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-CreateRepository
Here is the JSON that works successfully: (only passing required fields)
{
"rclass" : "virtual",
"packageType": "nuget"
}
However, it appears that when I try to add any other properties to it I get failures. Here is everything I would like to pass followed by the error I get when I do. (Sanitized values for public posting.)
{
"rclass" : "virtual",
"packageType": "nuget",
"repositories": ["nuget-local,nuget-remote"],
"description": "Nuget virtual repository.",
"notes": "Created by PowerShell script.",
"includesPattern": "*.nupkg",
"excludesPattern": "*mvn,*npm",
"defaultDeploymentRepo": "nuget-local"
}
Invoke-WebRequest : The remote server returned an error: (400) Bad Request. At [path to ps1 file.]:226 char:5 + Invoke-WebRequest -Method Put -Uri $resource -Body $RepoConfig -H ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
Thank you for your time.
"repositories": ["nuget-local,nuget-remote"],
line should be"repositories": ["nuget-local","nuget-remote"],
. It should be a list of two strings, rather than a list of one string with a comma in it. – DarthFennec