{"action":"created","issue":{"url":"https://api.github.com/repos/PowerShell/PowerShell/issues/2862","repository_url":"https://api.github.com/repos/PowerShell/PowerShell","labels_url":"https://api.github.com/repos/PowerShell/PowerShell/issues/2862/labels{/name}","comments_url":"https://api.github.com/repos/PowerShell/PowerShell/issues/2862/comments","events_url":"https://api.github.com/repos/PowerShell/PowerShell/issues/2862/events","html_url":"https://github.com/PowerShell/PowerShell/pull/2862","id":194490042,"number":2862,"title":"Invoke-RestMethod cmdlet error if the response is neither JSON nor XML","user":{"login":"2xmax","id":2508022,"avatar_url":"https://avatars.githubusercontent.com/u/2508022?v=3","gravatar_id":"","url":"https://api.github.com/users/2xmax","html_url":"https://github.com/2xmax","followers_url":"https://api.github.com/users/2xmax/followers","following_url":"https://api.github.com/users/2xmax/following{/other_user}","gists_url":"https://api.github.com/users/2xmax/gists{/gist_id}","starred_url":"https://api.github.com/users/2xmax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/2xmax/subscriptions","organizations_url":"https://api.github.com/users/2xmax/orgs","repos_url":"https://api.github.com/users/2xmax/repos","events_url":"https://api.github.com/users/2xmax/events{/privacy}","received_events_url":"https://api.github.com/users/2xmax/received_events","type":"User","site_admin":false},"labels":[{"id":427063083,"url":"https://api.github.com/repos/PowerShell/PowerShell/labels/cla-required","name":"cla-required","color":"e11d21","default":false},{"id":486892834,"url":"https://api.github.com/repos/PowerShell/PowerShell/labels/Review%20-%20Needed","name":"Review - Needed","color":"bfd4f2","default":false}],"state":"open","locked":false,"assignee":{"login":"daxian-dbw","id":127450,"avatar_url":"https://avatars.githubusercontent.com/u/127450?v=3","gravatar_id":"","url":"https://api.github.com/users/daxian-dbw","html_url":"https://github.com/daxian-dbw","followers_url":"https://api.github.com/users/daxian-dbw/followers","following_url":"https://api.github.com/users/daxian-dbw/following{/other_user}","gists_url":"https://api.github.com/users/daxian-dbw/gists{/gist_id}","starred_url":"https://api.github.com/users/daxian-dbw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daxian-dbw/subscriptions","organizations_url":"https://api.github.com/users/daxian-dbw/orgs","repos_url":"https://api.github.com/users/daxian-dbw/repos","events_url":"https://api.github.com/users/daxian-dbw/events{/privacy}","received_events_url":"https://api.github.com/users/daxian-dbw/received_events","type":"User","site_admin":false},"assignees":[{"login":"daxian-dbw","id":127450,"avatar_url":"https://avatars.githubusercontent.com/u/127450?v=3","gravatar_id":"","url":"https://api.github.com/users/daxian-dbw","html_url":"https://github.com/daxian-dbw","followers_url":"https://api.github.com/users/daxian-dbw/followers","following_url":"https://api.github.com/users/daxian-dbw/following{/other_user}","gists_url":"https://api.github.com/users/daxian-dbw/gists{/gist_id}","starred_url":"https://api.github.com/users/daxian-dbw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daxian-dbw/subscriptions","organizations_url":"https://api.github.com/users/daxian-dbw/orgs","repos_url":"https://api.github.com/users/daxian-dbw/repos","events_url":"https://api.github.com/users/daxian-dbw/events{/privacy}","received_events_url":"https://api.github.com/users/daxian-dbw/received_events","type":"User","site_admin":false}],"milestone":null,"comments":3,"created_at":"2016-12-09T01:22:27Z","updated_at":"2016-12-11T04:13:14Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/PowerShell/PowerShell/pulls/2862","html_url":"https://github.com/PowerShell/PowerShell/pull/2862","diff_url":"https://github.com/PowerShell/PowerShell/pull/2862.diff","patch_url":"https://github.com/PowerShell/PowerShell/pull/2862.patch"},"body":"This change fixes the Invoke-RestMethod cmdlet behavior if the response is neither XML nor JSON, e.g. just a plain text from a webservice.\r\n\r\n**Before the change:**\r\n```\r\nPS> Invoke-RestMethod http://httpbin.org/encoding/utf8\r\nInvoke-RestMethod : Unexpected character encountered while parsing value: <. Path '', line 0, position 0.\r\nAt line:1 char:1\r\n+ Invoke-RestMethod http://httpbin.org/encoding/utf8\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n  + CategoryInfo : NotSpecified: (:) [Invoke-RestMethod], JsonReaderException\r\n  + FullyQualifiedErrorId : Newtonsoft.Json.JsonReaderException,Microsoft.PowerShell.Commands.InvokeRestMethodComman\r\n  d\r\n```\r\n**After the change:**\r\n```\r\nPS> Invoke-RestMethod http://httpbin.org/encoding/utf8\r\n<h1>Unicode Demo</h1>\r\n...\r\n```\r\n\r\ntodo: I am going to refactor ConvertFromJsonCommand a little bit in order to remove the duplication and eliminate some ifdef sections"},"comment":{"url":"https://api.github.com/repos/PowerShell/PowerShell/issues/comments/266260092","html_url":"https://github.com/PowerShell/PowerShell/pull/2862#issuecomment-266260092","issue_url":"https://api.github.com/repos/PowerShell/PowerShell/issues/2862","id":266260092,"user":{"login":"2xmax","id":2508022,"avatar_url":"https://avatars.githubusercontent.com/u/2508022?v=3","gravatar_id":"","url":"https://api.github.com/users/2xmax","html_url":"https://github.com/2xmax","followers_url":"https://api.github.com/users/2xmax/followers","following_url":"https://api.github.com/users/2xmax/following{/other_user}","gists_url":"https://api.github.com/users/2xmax/gists{/gist_id}","starred_url":"https://api.github.com/users/2xmax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/2xmax/subscriptions","organizations_url":"https://api.github.com/users/2xmax/orgs","repos_url":"https://api.github.com/users/2xmax/repos","events_url":"https://api.github.com/users/2xmax/events{/privacy}","received_events_url":"https://api.github.com/users/2xmax/received_events","type":"User","site_admin":false},"created_at":"2016-12-11T04:13:14Z","updated_at":"2016-12-11T04:13:14Z","body":"Eliminated the duplication caused by platform-specific libs exceptions. Also, locally I've written some C# unit tests for the JsonObject class https://gist.github.com/2xmax/ced86b7f7d9bbcdf0d004fa507b9a314, but found only [a few C# unit tests](https://github.com/PowerShell/PowerShell/tree/master/test/csharp) in the project for some reason. If it makes sense, I can push the C# unit tests as well."}}
{"actor":{"display_login":"2xmax"}}