Lawrence Aiello Lawrence Aiello - 5 months ago 10
JSON Question

JSON Object Arrays in JFrog Mission Control API

I am using Mission Control version 1.1

I attempted to communicate to the REST API that I wanted to create a repository. My JSON input is below:

{
"scriptMappings": [{
"scriptNames": ["virtual-repo"],
"scriptUserInputs": [{
"TemplateExecutor#0#name#0": "%s"
}, {
"TemplateExecutor#0#region#0": "%s"
}],
"instanceName": "us-east-1a"
}]
}


I have verified that my configuration script allows both of those user variables. When I change the user input to only be one value like so (along with the config script):

{
"scriptMappings": [{
"instanceName": "us-east-1a",
"scriptUserInputs": {
"TemplateExecutor#0#name#0": "%s"
},
"scriptNames": ["virtual-repo"]
}]
}


The REST API works just fine.

The error message I get is huge, but it's basically a Jackson error that says "Can not deserialize instance of java.util.LinkedHashMap out of START_ARRAY token". I've worked with Jackson before and have received this when I couldn't deserialize a JSON array object properly into my data models, so I assume that is what's happening here.

Has anyone else had this issue, or resolved it?

Answer

This is a bug in JFrog. I have opened the following support ticket for reference: https://support.jfrog.com/support/tickets/40899

The correct JSON to accomplish this looks like the following:

{
    "scriptMappings":[
              {
                "instanceName" : "us-east-1a",
                "scriptNames" : ["docker-remote-repo"],
                "scriptUserInputs":
                {
                  "TemplateExecutor#0#region#0": "%s",
                  "TemplateExecutor#0#url#0": "%s",
                  "TemplateExecutor#0#name#0": "%s"
                }
              }
            ]
}
Comments