/*--------------------------------------------------------------------------------------------*/ protected virtual FabricResponse <T> GetFabricResponse(IClientContext pContext) { string fullPath = pContext.Config.ApiPath + Path + (Query != null ? "?" + Query : ""); pContext.LogInfo("Request initiated..."); //// try { pContext.LogInfo("Request Path: " + Method + " " + Path); pContext.LogInfo("Request URL: " + fullPath); IFabricHttpResponse wr = GetHttpWebResponse(fullPath); string data = StreamToString(wr.GetResponseStream()); pContext.LogDebug("Request Response: " + data); return(new FabricResponse <T>(JsonSerializer.DeserializeFromString <T>(data))); } catch (WebException we) { if (we.Response == null) { throw new Exception("No Fabric response from " + Method + " " + fullPath); } string data = StreamToString(we.Response.GetResponseStream()); bool isOauthErr = (data.Length > 9 && data.Substring(0, 9) == "{\"error\":"); bool isRespErr = typeof(FabResponse).IsAssignableFrom(typeof(T)); pContext.LogDebug("Request Error: " + data + " (IsError=" + isRespErr + ", IsOauthError=" + isOauthErr + ")"); if (isRespErr) { FabResponse frErr = JsonSerializer.DeserializeFromString <FabResponse>(data); return(new FabricResponse <T>(frErr, we)); } if (isOauthErr) { FabOauthError oerr = JsonSerializer.DeserializeFromString <FabOauthError>(data); return(new FabricResponse <T>(oerr, we)); } throw; } }