Errors Syncing Environment using PUT /environments


#1

My team currently works on their postman collections & environments stored in an Azure DevOps git repo. I’m currently working on a side project to automatically sync the collections stored in the repo with a postman team workspace.

The idea is basically this:

  1. grab all collections & environments in git
  2. grab all collections & environments in postman workspace (using the GET /workspace API)
  3. match collection in git to collection in workspace
  4. update collection in workspace with git collection
  5. do the same for environments.

I have steps 1-4 working fine, but environments are not working for some reason. I’m always getting a 400 bad request with the following error body:

        "error": {
            "name": "invalidParamsError",
            "message": "The request had invalid parameters",
            "details": {
                "param": "key"
            }
        }
    }

Due to corporate policy I can’t send the entire environment JSON over, but the data I’m sending to Postman in the PUT request seems to be valid according to the API reference. Has anyone seen this before?

{
  "environment": {
"name":"E2E-ENV-Dev0","values":
[
{"key":"testAgency","value":"subsystem","enabled":true},
{"key":"completeFw","value":"amp_sdm660_64_IL01_AMP_R01.00.45","enabled":true},
{"key":"badFw","value":"","enabled":true},
{"key":"incompleteFw","value":"amp_sdm660_64_IL01_AMP_R1.00.24_IL01_AMP_R1.00.00","enabled"
:true},
{"key":"nonExistFw","value":"somefwpackage","enabled":true},
{"key":"postedFw","value":"","enabled":true},
{"key":"testName","value":"10.3-POST-FwRefAgency-BadInputs - Status Code 400","enabled":true},{"key":"version","value":"v1","enabled":true},
{"key":"keyid","value":"0","enabled":true},
{"key":"currentTestAgency","value":"subsystem","enabled":true},
{"key":"deviceName","value":"amp_sdm660_64","enabled":true},
{"key":"azureAgencyFwTable","value":"agencyFirmware","enabled":true},
{"key":"testAgencyName","value":"TestAgency1","enabled":true},
{"key":"deviceName","value":"amp_sdm660_64","enabled":true},
{"key":"newAgencyId","value":"","enabled":true},
{"key":"testAgencyName2","value":"TestAgency2","enabled":true},
{"key":"azureAgencyFwTable","value":"agencyFirmware","enabled":true},
{"key":"flow10AgencyName","value":"subsystem","enabled":true},
{"key":"rmApiTestAgency","value":"subsystem","enabled":true}
]}
}