1

This Code;

public void ProcessRequest(HttpContext context)
{
    string jSon = new StreamReader(context.Request.InputStream).ReadToEnd();
    string result = LETSGO.BUSINESS.Process.ApiProcesRequest(jSon);        
    context.Response.ContentType = "application/json";
    context.Response.Write(result);
}

Error : Unexpected character encountered while parsing value: s. Path '', line 0, position 0.

How do I fix error ?

This function send;

public static string ApiProcesRequest(string request)
    {
        Result result = new Result();
        try
        {
            var req = JsonConvert.DeserializeObject<Request>(request);
            switch (req.RequestType)
            {
                #region 1002 - Kullanıcı şifre hatırlatma
                case "1002":
                    result = UserProcess.PasswordReminder(request);
                    return JsonConvert.SerializeObject(result);
                    break;
                #endregion } } }
2
  • You're missing the most important piece - what are you parsing into your function? Commented Jun 25, 2014 at 12:28
  • 1
    Which line throws the exception? Also, can you show us the JSON that it's trying to parse (i.e. the data that's read from the input stream)? Commented Jun 25, 2014 at 12:38

1 Answer 1

2
string jSon = new StreamReader(context.Request.InputStream).ReadToEnd();

Here you might got the string like s.Path, it can not be deserialize due to it's not a well-formed json object.

Sign up to request clarification or add additional context in comments.

3 Comments

@Ekskalibbur please use debug , to see the content of 'jSon', this string must contains something like 's.Path', and this is not a json object!
Screenshot; {"Code":"Err","Message":"Hata! Object reference not set to an instance of an object.","Value":null,"UserId":0} Help me !
@Ekskalibbur all values should be wrapped with double quotes, the "null" and "0" are not. Add the quotes and it might work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.