/// <summary> /// Convert the http response message into a simple structure suitable for apps to process /// </summary> /// <param name="response">The response to convert</param> /// <returns>A simple rsponse</returns> private async static Task <StandardResponse> TranslateResponse(HttpResponseMessage response) { StandardResponse standardResponse; if (response.StatusCode == HttpStatusCode.Created) { dynamic responseObject = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); standardResponse = new CreateSuccessResponse { StatusCode = response.StatusCode, OneNoteClientUrl = responseObject.links.oneNoteClientUrl.href, OneNoteWebUrl = responseObject.links.oneNoteWebUrl.href }; } else { standardResponse = new StandardErrorResponse { StatusCode = response.StatusCode, Message = await response.Content.ReadAsStringAsync() }; } // Extract the correlation id. Apps should log this if they want to collcet the data to diagnose failures with Microsoft support IEnumerable <string> correlationValues; if (response.Headers.TryGetValues("X-CorrelationId", out correlationValues)) { standardResponse.CorrelationId = correlationValues.FirstOrDefault(); } return(standardResponse); }
/// <summary> /// Convert the http response message into a simple structure suitable for apps to process /// </summary> /// <param name="response">The response to convert</param> /// <returns>A simple rsponse</returns> private async static Task<StandardResponse> TranslateResponse(HttpResponseMessage response) { StandardResponse standardResponse; if (response.StatusCode == HttpStatusCode.Created) { dynamic responseObject = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); standardResponse = new CreateSuccessResponse { StatusCode = response.StatusCode, OneNoteClientUrl = responseObject.links.oneNoteClientUrl.href, OneNoteWebUrl = responseObject.links.oneNoteWebUrl.href }; } else { standardResponse = new StandardErrorResponse { StatusCode = response.StatusCode, Message = await response.Content.ReadAsStringAsync() }; } // Extract the correlation id. Apps should log this if they want to collcet the data to diagnose failures with Microsoft support IEnumerable<string> correlationValues; if (response.Headers.TryGetValues("X-CorrelationId", out correlationValues)) { standardResponse.CorrelationId = correlationValues.FirstOrDefault(); } return standardResponse; }