{"action":"created","issue":{"url":"https://api.github.com/repos/AdrianBegg/vCloud/issues/1","repository_url":"https://api.github.com/repos/AdrianBegg/vCloud","labels_url":"https://api.github.com/repos/AdrianBegg/vCloud/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/AdrianBegg/vCloud/issues/1/comments","events_url":"https://api.github.com/repos/AdrianBegg/vCloud/issues/1/events","html_url":"https://github.com/AdrianBegg/vCloud/issues/1","id":293899650,"number":1,"title":"Potential problem if there is more than one connection to vcloud in the current session.","user":{"login":"ihumster","id":557105,"avatar_url":"https://avatars1.githubusercontent.com/u/557105?v=4","gravatar_id":"","url":"https://api.github.com/users/ihumster","html_url":"https://github.com/ihumster","followers_url":"https://api.github.com/users/ihumster/followers","following_url":"https://api.github.com/users/ihumster/following{/other_user}","gists_url":"https://api.github.com/users/ihumster/gists{/gist_id}","starred_url":"https://api.github.com/users/ihumster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ihumster/subscriptions","organizations_url":"https://api.github.com/users/ihumster/orgs","repos_url":"https://api.github.com/users/ihumster/repos","events_url":"https://api.github.com/users/ihumster/events{/privacy}","received_events_url":"https://api.github.com/users/ihumster/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-02T14:08:07Z","updated_at":"2018-02-02T15:37:05Z","closed_at":null,"author_association":"NONE","body":"Test-vCloudEnvironment does not check for more than one connection in the current session. $global:DefaultCIServers.SessionSecret in other cmdlets will return an array, not a string."},"comment":{"url":"https://api.github.com/repos/AdrianBegg/vCloud/issues/comments/362619844","html_url":"https://github.com/AdrianBegg/vCloud/issues/1#issuecomment-362619844","issue_url":"https://api.github.com/repos/AdrianBegg/vCloud/issues/1","id":362619844,"user":{"login":"ihumster","id":557105,"avatar_url":"https://avatars1.githubusercontent.com/u/557105?v=4","gravatar_id":"","url":"https://api.github.com/users/ihumster","html_url":"https://github.com/ihumster","followers_url":"https://api.github.com/users/ihumster/followers","following_url":"https://api.github.com/users/ihumster/following{/other_user}","gists_url":"https://api.github.com/users/ihumster/gists{/gist_id}","starred_url":"https://api.github.com/users/ihumster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ihumster/subscriptions","organizations_url":"https://api.github.com/users/ihumster/orgs","repos_url":"https://api.github.com/users/ihumster/repos","events_url":"https://api.github.com/users/ihumster/events{/privacy}","received_events_url":"https://api.github.com/users/ihumster/received_events","type":"User","site_admin":false},"created_at":"2018-02-02T15:37:05Z","updated_at":"2018-02-02T15:37:05Z","author_association":"NONE","body":"Also I refactored your 3 methods Get-\\Publish-\\Update-vCloudAPICall into Invoke-vCloudRequest:\r\n\r\n`function Invoke-vCloudRequest {\r\n#region Params\r\n[OutputType([xml])]\r\n[CmdletBinding()]\r\nParam(\r\n[parameter(Mandatory=$true,ValueFromPipeline=$true)]\r\n[string]$Href,\r\n[parameter(Mandatory=$false)]\r\n[string]\r\n$Version = \"20.0\",\r\n[parameter(Mandatory=$false)]\r\n$Body,\r\n[parameter(Mandatory=$false)]\r\n[string]$ContentType,\r\n[parameter(Mandatory=$true)]\r\n[ValidateSet(\"Get\",\"Post\",\"Put\")]\r\n[string]$Method\r\n)\r\n#endregion\r\n    \r\n    if(!(Test-vCloudEnvironment)){\r\n\t\tBreak\r\n\t}\r\n\r\n\r\n    $webclient = New-Object System.Net.WebClient\r\n    $webclient.Headers.Add(\"x-vcloud-authorization\",$global:DefaultCIServers.SessionSecret)\r\n    $webclient.Headers.Add(\"Accept\",\"application/*+xml;version=$Version\")\r\n    $webclient.Headers.Add(\"Accept-Language: en\")\r\n    if ($ContentType) {\r\n        $webclient.Headers.Add(\"Content-Type\", $ContentType)\r\n    }\r\n    \r\n    if($method -ne \"Get\"){\r\n        if($Body -and $Body.gettype() -eq [string]) {\r\n            [byte[]]$byteArray = [System.Text.Encoding]::ASCII.GetBytes($Body)\r\n        } elseif ($Body -and $Body.gettype() -eq [xml]) {\r\n            [byte[]]$byteArray = [System.Text.Encoding]::ASCII.GetBytes($Body.OuterXml)\r\n        } else {\r\n            throw \"Body parameter has wrong type. Use [string] or [xml] types\"\r\n            Break\r\n        }\r\n    }\r\n    switch ($Method) {\r\n        \"Get\" {\r\n            try{\r\n\t            [xml]$xmlResponse = $webclient.DownloadString([uri]::EscapeUriString($Href))\r\n            } catch {\r\n\t            throw \"An error occured attempting to make HTTP GET against $Href\"\r\n            }\r\n            return $xmlResponse\r\n        }\r\n        \r\n        \"Post\" {\r\n            try{\r\n                $UploadData = $webclient.UploadData($Href, \"POST\", $bytearray)\r\n            } catch {\r\n                throw \"An error occured attempting to make HTTP POST against $URI\"\r\n            }\r\n        }\r\n        \"Put\" {\r\n            try{\r\n                $UploadData = $webclient.UploadData($Href, \"PUT\", $bytearray)\r\n            } catch {\r\n                throw \"An error occured attempting to make HTTP PUT against $URI\"\r\n            }\r\n\r\n        }\r\n    }\r\n\r\n}`"}}
{"actor":{"display_login":"ihumster"}}