ShopifySharp icon indicating copy to clipboard operation
ShopifySharp copied to clipboard

ShopifyService ExecuteRequestAsync not returning PolicyResult

Open smillerworld opened this issue 7 years ago • 0 comments

Hi, I am trying to get a list of orders. The order data is returned from Shopify but policyResult is not being returned by the function. I am using .Net 4.5 and had to make some minor changes to get the data returned from Shopify. My code is below and any help would be greatly appreciated.

protected async Task<T> ExecuteRequestAsync<T>(RequestUri uri, HttpMethod method, HttpContent content = null, string rootElement = null) where T : new() { using (var baseRequestMessage = PrepareRequestMessage(uri, method, content)) { var policyResult = await _ExecutionPolicy.Run<T>(baseRequestMessage, async (requestMessage) => { System.Net.ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; var request = _Client.SendAsync(requestMessage).ConfigureAwait(false);
using (var response = await request) { var rawResult = await response.Content.ReadAsStringAsync();

                    //Check for and throw exception when necessary.
                    CheckResponseExceptions(response, rawResult);

                    // This method may fail when the method was Delete, which is intendend.
                    // Delete methods should not be parsing the response JSON and should instead
                    // be using the non-generic ExecuteRequestAsync.
                    var reader = new JsonTextReader(new StringReader(rawResult));
                    var data = _Serializer.Deserialize<JObject>(reader).SelectToken(rootElement);
                    var result = data.ToObject<T>();
                    var rt = new RequestResult<T>(response, result, rawResult);
                    
                    return new RequestResult<T>(response, result, rawResult);                        
                }                  
            });

            return policyResult;
        }
    }

smillerworld avatar Sep 28 '18 08:09 smillerworld