I am struggling to find out why my query throws an exception when I do a specific query. Is there a way to see the raw response from Salesforce or .NET? Query string in itemQueryString is running correctly using workbench so I have ruled out query string problem.
Here is my code:
try{
var results = forceClient.QueryAsync<JObject>(itemQueryString).Result;
//do something...
} catch (Exception e) {
System.Diagnostics.Trace.TraceError("Error while querying items " + e.ToString());
}
Here is the exception
"System.AggregateException: One or more errors occurred. --->
Newtonsoft.Json.JsonReaderException: Unexpected character encountered while
parsing value: <. Path '', line 0, position 0.\r\n at
Newtonsoft.Json.JsonTextReader.ParseValue()\r\n at
Newtonsoft.Json.JsonTextReader.Read()\r\n at
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.
ReadForType(JsonReadrr reader, JsonContract contract, Boolean
hasConverter)\r\n at
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.
Deserialize(JsonReader reader, Type objectType, Boolean
checkAdditionalContent)\r\n at Newtonsoft.Json.JsonSerializer.
DeserializeInternal(JsonReader reader, Type objectType)\r\n at
Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type,
JsonSerializerSettings settings)\r\n at
Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value,
JsonSerializerSettings settings)\r\n at
Salesforce.Common.ServiceHttpClient.<HttpGetAsync>d__1`1.MoveNext()\r\n --
- End of inner exception stack trace ---\r\n at
System.Threading.Tasks.Task.ThrowIfExceptional(Boolean
includeTaskCanceledExceptions)\r\n at
System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout,
CancellationToken cancellationToken)\r\n at
System.Threading.Tasks.Task.Wait()\r\n at
ReportDataManager.PopulateItems(ItemQueryString) in
ReportDataManager.cs:line 39\r\n---> (Inner Exception #0)
Newtonsoft.Json.JsonReaderException: Unexpected character encountered while
parsing value: <. Path '', line 0, position 0.\r\n at
Newtonsoft.Json.JsonTextReader.ParseValue()\r\n at
Newtonsoft.Json.JsonTextReader.Read()\r\n at
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.
ReadForType(JsonReader reader, JsonContract contract, Boolean
hasConverter)\r\n at
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.
Deserialize(JsonReader reader, Type objectType, Boolean
checkAdditionalContent)\r\n at
Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type
objectType)\r\n at Newtonsoft.Json.JsonConvert.DeserializeObject(String
value, Type type, JsonSerializerSettings settings)\r\n at
Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value,
JsonSerializerSettings settings)\r\n at
Salesforce.Common.ServiceHttpClient.<HttpGetAsync>d__1`1.MoveNext()<---\r\n"
Looks like it's returning unexpected result so query result cannot be parsed but I don't know how to get the raw response so I can see what is wrong with the query.
I tried to use system.net trace according to this blog; however, my trace is encrypted I cannot see the response. https://blogs.msdn.microsoft.com/waws/2017/03/14/how-to-get-a-system-net-trace-of-your-c-web-job/