none
Unexpected character encountered while parsing value: P. Path error RRS feed

  • Question

  • Hi,

    I have created a console application which is sending json request and getting response and i am deserializing it using JsonConvert.DeserializeObject and getting output value .

    It is running fine when I ran it  from console application(.exe).I then,change it to a class library(.dll) and adding it as assembly in SQL Server along with its dependent assemblies.

    Finally as per the requirement, I create a scalar valued function and returning the response as output .But when i execute it i get this below error.

    A .NET Framework error occurred during execution of user-defined routine or aggregate "GetSSNByPerNerTest": 
    Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: P. Path '', line 0, position 0.
    Newtonsoft.Json.JsonReaderException: 
       at Newtonsoft.Json.JsonTextReader.ParseValue()
       at Newtonsoft.Json.JsonTextReader.ReadInternal()
       at Newtonsoft.Json.JsonTextReader.Read()
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter)
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
       at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
       at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
       at <Dllname>.<MethodName>()

    Any help would be really useful.

    Thanks 

    Sai Prateek

    • Moved by Bob Beauchemin Thursday, June 16, 2016 5:09 PM Moved to forum for client-side SqlClient for best results
    Thursday, June 16, 2016 10:28 AM

All replies

  • Greetings Prateek,

    So your question is:
    What kind of code is in the function "GetSSNByPerNerTest" that my JSON-response does not get processed.

    The answer:
    We don't know.

    But to help you;
    JsonConvert.DeserializeObject  expect a JSON-object not a file-path.

    with kind regards,
    Sebastian

    Thursday, June 16, 2016 11:04 AM
  • Hi Sebastian,

    The response I am getting is a Json-string object and then i am deserializing it using below code.

    Where Rootobject is class which has same properties as json reponse.

           var root = JsonConvert.DeserializeObject<RootObject>(response);

    But the same code works fine when i ran it as console application,but gives me above posted error when I am calling it from a scalar function which has same name as method name i.e GetSSNByPerNerTest.

    Regards 

    Sai Prateek

    Thursday, June 16, 2016 12:14 PM
  • Hi Prateek__,

    According to your description, it works well on console application, but it doesn't on a scalar function. Please check the input arguments when you call the scalar function. In addition, If you still have the issue, Could you please provide a simple demo which could reproduce the issue. it helps to resolve the issue.

    Best regards,

    Cole Wu


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, June 17, 2016 4:38 AM
    Moderator