Error while Deserializing JSON

Hello Team,

I have been trying to connect to orchestrator API and deserialize the output but I am facing an issue while deseriailizing…
Error Message : “Deserialize JSON: Unexpected character encountered while parsing value: <. Path ‘’, line 0, position 0.”

Could any one help on this topic?

Thanks in Advance,

@priya.rani

Welcome to forums

Check below for your reference

As the post explained that try to check whether your JSON is in correct format by going to https://jsonlint.com/

Hope this may help you

Thanks

Probably because the API reply isn’t in JSON format, but some form of XML or even HTML (incorrect requests can easily throw an unathorised or page not found html reply).
Write the raw reply string into your output first, so you know wether it is actual JSON to deserialize.

Hello @Srini84,
I have already tried that and it says that it is a valid JSON.
Thanks

Can you share that output?

@priya.rani

It’s really helpful to trace the issue if you can upload a sample JSON file

Thanks

Hello @Srini84,

I have tried testing the JSON file on the mentioned URL and getting the below error:

Error: Parse error on line 1:
< !doctype html > <
^
Expecting ‘STRING’, ‘NUMBER’, ‘NULL’, ‘TRUE’, ‘FALSE’, ‘{’, ‘[’, got ‘undefined’

Could you please check this?
Thanks

Hello @Jeroen_van_Loon and @Srini84,
Sure, I will check and share the output.
Thanks

@priya.rani

In the Json structure there was multiple things missing

So recheck those, If you are getting this JSON from any other source then you can check else share the sample output file

Thanks

Hi @priya.rani
You can test the response the API is giving you in a page like http://json.parser.online.fr/ so you know the reponse is OK and then try to deserialize it in UiPath.

Hello @GersonTun,
I have checked the JSON in the mentioned URL and it seems the output from http request is not in correct json format.
Thanks

Hello @Srini84 @Jeroen_van_Loon,
it is not allowing me to upload the attachment

(post deleted by author)

Though I am not allowed to upload the json file which is a result from http request, pasting in here:

<!doctype html><html lang="en" style="height:100%;scrollbar-width:none"><head><meta charset="utf-8"/><meta name="robots" content="noindex"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/>{"ENVIRONMENT":"prd","FEATURE_FLAGS":{"enable-service-aifabric":{"value":true,"source":"LaunchDarkly"},"IsMultiregionOrgCreationEnabledForPortal":{"value":false,"source":"LaunchDarkly"},"enableAddDirectoryUsers":{"value":false,"source":"LaunchDarkly"},"enable-pm-users-link":{"value":false,"source":"DefaultValuesMap"}}}</body></html>

could you please check?
Thanks

Well there is your answer…
That is not JSON, that is HTML… or at least the outer shell of it. (Hence the illegal < character on line 0, position 0, the first character in your output)

<!doctype html>
<html lang="en" style="height:100%;scrollbar-width:none">
<head>
<meta charset="utf-8"/>
<meta name="robots" content="noindex"/>
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/>
{
	"ENVIRONMENT":"prd",
 	"FEATURE_FLAGS": {
		"enable-service-aifabric":{
			"value":true,
			"source":"LaunchDarkly"
		},
		"IsMultiregionOrgCreationEnabledForPortal":{
			"value":false,
			"source":"LaunchDarkly"
		},
		"enableAddDirectoryUsers":{
			"value":false,
			"source":"LaunchDarkly"
		},
		"enable-pm-users-link":{
			"value":false,
			"source":"DefaultValuesMap"
		}
	}
}
</body>
</html>

So you cannot deserialize it.

Obviously this does not match the requested output you desire. Can you share your activity? What type of request are you sending to the orchestrator?