Create Release API fails with conversion error

We automate a lot of our CD pipeline through your APIs. Recently, we were making changes to the automation we have that creates a release. This has worked in the past, but is now failing. We have been over the json over and over and cannot see what the issue is.

failed: [win-octopus-release-test.case-2] => {“content”: “{\r\n “ErrorMessage”: “Error converting value \”[{‘StepName’: ‘SpaceAcademy’, ‘Version’: ‘1.0.0.166’}]\” to type ‘System.Collections.Generic.List1[Octopus.Client.Model.SelectedPackage]'. Path 'SelectedPackages', line 4, position 75.\"\r\n}", "content_type": "application/json; charset=utf-8", "date": "Wed, 18 May 2016 20:52:09 GMT", "failed": true, "json": {"ErrorMessage": "Error converting value \"[{'StepName': 'SpaceAcademy', 'Version': '1.0.0.166'}]\" to type 'System.Collections.Generic.List1[Octopus.Client.Model.SelectedPackage]’. Path ‘SelectedPackages’, line 4, position 75."}, “redirected”: false, “server”: “Microsoft-HTTPAPI/2.0”, “status”: 500, “transfer_encoding”: “chunked”}
msg: Status code was not [201]

Any help is appreciated.

Thanks.

Hi Rick,

Thanks for reaching out. We’d need to see the JSON body you were previously sending on the API POST (when it was working) and the current one to see what’s going on.

Seems like you are trying to pass a hardcoded value for a nuget package in a step, but that’s blowing up somewhere.

Thanks,
Dalmiro

Hi Dalmiro,

Original format

{"ProjectId": "Projects-25", "ReleaseNotes": "win-octopus-release-test.case-2", "Version": "1.i", "SelectedPackages": [{"StepName": "SpaceAcademy", "Version": "1.0.0.166"}]}

New format

{
ProjectId: "Projects-25",
Version: "1.i",
SelectedPackages: "[{'StepName': 'SpaceAcademy', 'Version': '1.0.0.166'}]",
ReleaseNotes: "win-octopus-release-test.case-2"
}

Could it be the newlines?

I think I just figured it out. I took away the quotes around the SelectedPackages array and it successfully created a release.

I think we can close this issue now.

Yup that should be it - If between double quotes JSON will interpret it as a string, instead of an array (between square brackets) which is what the API is expecting.

Kudos for figuring it out :slight_smile: