title: Identify Cause of Serialization Error Coming From Inside Library/NuGet Package
body: <p>Sometimes when calling the Mastercard MATCH API via the NuGet package MasterCard-Match, I will get a JSON deserialization exception:</p>
  
  <blockquote>
    <p>Unexpected character encountered while parsing value: &lt;. Path '',
    line 0, position 0. </p>
  </blockquote>
  
  <p>The exception is from MasterCard.Core with an inner exception from Newtonsoft.Json, both have the same message.</p>
  
  <p>It looks like I'm receiving HTML ('&lt;' at line 0, position 0) and the library is trying to deserialize it as JSON. My guess is that the MasterCard API is sending back an HTML error page instead of a JSON error. But I can't step into the function call to "see" the response its getting before throwing the exception.</p>
  
  <p>As per the <a href="https://developer.mastercard.com/documentation/match/3" rel="nofollow noreferrer">documentation</a> I create a request map with the provided data and call <code>TerminationInquiryRequest.Create(map)</code>, this is the line the exception is thrown. This function call is a black box, I can't step into it, it just throws the exception.</p>
  
  <pre class="lang-cs prettyprint-override"><code>try
  {
    RequestMap requestMap = CreateRequestMap(); 
  
    // This line throws the exception
    TerminationInquiryRequest apiResponse = TerminationInquiryRequest.Create(requestMap);
  }
  catch(Exception e)
  {
    // Exception handling
  }
  </code></pre>
  
  <p>I've made over 11,000+ calls using this library and only 32 have had this error, but of course I get to hear about it every time it happens.</p>
  
  <p>Is there any way to debug libraries that I'm not aware of, or a way to view the response that the library is getting from the API?</p>
  
  <p>I already have some logic to wait and retry the call if it fails.</p>