Skip to content

JSON conversion error #699

Description

@azra1l

Description

I am getting this error for every command i run against the Jira API:

ConvertFrom-Json: Conversion from JSON failed with error: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.

Steps To Reproduce

Import module
Create new session
Run any JiraPS cmdlet

Expected behavior

Proper output of the requested ressource

Screenshots

-/-

Your Environment

Get-Module JiraPS -ListAvailable | Select Name, Version                                                                                                                                                                                                                                                        

Name   Version
----   -------
JiraPS 2.16.0

$PSVersionTable          
                                                                                                                                                                                                                                                                                      
Name                           Value
----                           -----
PSVersion                      7.5.3
PSEdition                      Core
GitCommitId                    7.5.3
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0, 5.0, 5.1, 6.0, 7.0}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Possible Solution

Not a solution, but my best guess for the cause:
This module expects a json string as content from the webrequest but gets xml instead.

This is the output i get - including verbose and debug switches (i obfuscated our instance address):

Get-JiraServerInfo -Force -Verbose -Debug
                                                                                                                                                                                                                                                                      
VERBOSE: [Get-JiraServerInformation] Function started
VERBOSE: [Get-JiraConfigServer] Function started
DEBUG: [Get-JiraConfigServer] ParameterSetName: __AllParameterSets
DEBUG: [Get-JiraConfigServer] PSBoundParameters:
Key         Value
---         -----
ErrorAction  Stop


VERBOSE: [Get-JiraConfigServer] Complete
DEBUG: [Get-JiraServerInformation] ParameterSetName: __AllParameterSets
DEBUG: [Get-JiraServerInformation] PSBoundParameters:
Key     Value
---     -----
Force   True
Verbose True
Debug   True


DEBUG: [Get-JiraServerInformation] Invoking JiraMethod with $parameter
VERBOSE: [Invoke-JiraMethod] Function started
DEBUG: [Invoke-JiraMethod] ParameterSetName: __AllParameterSets
DEBUG: [Invoke-JiraMethod] PSBoundParameters:
Key        Value
---        -----
Credential System.Management.Automation.PSCredential
URI        https://xxx.atlassian.net/rest/api/2/serverInfo
Method     Get


VERBOSE: [ConvertTo-GetParameter] Making HTTP get parameter string out of a hashtable
VERBOSE:
Name                           Value
----                           -----
maxResults                     25


VERBOSE: [Get-JiraSession] Function started
DEBUG: [Get-JiraSession] ParameterSetName: __AllParameterSets
DEBUG: [Get-JiraSession] PSBoundParameters:
Key                    Value
---                    -----
ErrorAction SilentlyContinue


VERBOSE: [Get-JiraSession] Using Session saved in PrivateData
VERBOSE: [Get-JiraSession] Complete
VERBOSE: [Invoke-JiraMethod] Get https://xxx.atlassian.net/rest/api/2/serverInfo?maxResults=25
DEBUG: [Invoke-JiraMethod] Invoke-WebRequest with $splatParameters:
Name                           Value
----                           -----
WebSession                     Microsoft.PowerShell.Commands.WebRequestSession
Method                         Get
Verbose                        False
UseBasicParsing                True
ContentType                    application/json; charset=utf-8
Uri                            https://xxx.atlassian.net/rest/api/2/serverInfo?maxResults=25
ErrorAction                    Stop
Headers                        {[Accept-Charset, utf-8], [Accept, application/json]}


DEBUG: [Invoke-JiraMethod] Executed WebRequest. Access $webResponse to see details
VERBOSE: [Test-ServerResponse] Checking HTTP Response
VERBOSE: [Invoke-JiraMethod] Status code: 200
WARNING: [Get-JiraServerInformation] Could not retrieve server information: Conversion from JSON failed with error: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.

VERBOSE: [Get-JiraServerInformation] Complete

DeploymentType
--------------
Server

I think i managed to pin it down, it appears to fail in the Resolve-JiraWebResponse cmdlet,

line 73: $response = ConvertFrom-Json ([Text.Encoding]::UTF8.GetString($WebResponse.RawContentStream.ToArray()))

but i don't know enough about this module to give any advice on a fix.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions