1

I am trying to update a variable group from an Azure DevOps Pipeline. This is the API documentation from Microsoft. I am calling this API via Postman with HTTP PUT and a Header Authorization Basic {PAT}. The URL is https://dev.azure.com/{organization}/_apis/distributedtask/variablegroups/{groupId}?api-version=6.0-preview.2 Regardless of the JSON body it always returns:

{
  "$id": "1",
  "innerException": null,
  "message": "Project information name is not valid for variable group.",
  "typeName": "System.ArgumentException, mscorlib",
  "typeKey": "ArgumentException",
  "errorCode": 0,
  "eventId": 0
 }

Sample JSON Bodies:

Test 1

{
  "type": "Vsts",
  "name":"JobStatus"
}

Test 2

{
  "variables": {
      "rest-var1": {
          "isSecret": false,
          "value": "rest-var-value-1"
      },
      "rest-var2": {
          "isSecret": false,
          "value": "rest-var-value-2"
      },
      "rest-var3": {
          "isSecret": false,
          "value": "rest-var-value-3"
      }
  },
  "name":"JobStatus"
}

If I call this same API with HTTP GET it returns all of the details of the group. This was reported as a bug to Microsoft but the page didn't provide any details as to the solution.

1 Answer 1

3

"Project information name is not valid for variable group."

The error means that you need to define the project information in the Request Body.

Here is the Rest API example:

Rest API url:

PUT https://dev.azure.com/{organization}/_apis/distributedtask/variablegroups/{groupId}?api-version=6.0-preview.2

Request Body:

{
    "name":"{variablegroupname}",

    "type":"Vsts",
    "variables":{
        "var1":{
            "isSecret":false,
            "value": "xx"
            },
        "var2":{
            "isSecret":false,
            "value": "xx"
            },
        "var3":{
            "isSecret":false,
            "value": "xx"
            }
        },
        "variableGroupProjectReferences":[
            {
                "name":"{variablegroupname}",
                "projectReference":
                    {
                        "id":"{projectid}"  
                    }
            }
        ]
}
Sign up to request clarification or add additional context in comments.

6 Comments

Thank you so much for your input. To find the {projectid} which is mentioned in this answer you can use this question stackoverflow.com/questions/53866107/…. The first answer did not work for me but with the 2nd answer I was able to find the correct projectid.
So this works for me, thank you. One question: I noticed that if the group starts with several variables and I only specify one variable to update, it wipes all the other variables out. Is there a way to update a variable without wiping out the others in the group?
My variableGroupProjectReferences is null when i GET. I tries to put as it is (null) on [] I mean @() and always i get: Invoke-RestMethod: {"$id":"1","innerException":null,"message":"Project information name is not valid for variable group.","typeName":"System.ArgumentException, mscorlib","typeKey":"ArgumentException","errorCode":0,"eventId":0}
Same for me: "Project information name is not valid for variable group." Getting rather frustrated how documentation does not have the error
I also got the variableGroupProjectReferences as null but only when I get the variable group by name (query parameter: groupName=some-name). When I use ID I do get the variableGroupProjectReferences
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.