Note that there are some explanatory texts on larger screens.

plurals
  1. POKeep getting 21002 'java.lang.NullPointerException' on Apple's VerifyReceipt
    primarykey
    data
    text
    <p>I keep getting 21002 'java.lang.NullPointerException' errors from Apple when I try to test my In-App Purchases in the sandbox. This is what I have done:</p> <ul> <li>Set up the In-App Purchase products in iTunes Connect. I can successfully retrieve them via StoreKit.</li> <li>Set up test user in iTunes Connect.</li> <li>Application starts up, downloads the available In-App Purchase products, I trigger the In-App Purchase and Apple responds with the transactionReceipt, which I base64-encode on the iPhone and send to my C#/ASP.NET server.</li> <li>The server puts the received string into JSON (I tried it both with <code>NewtonSoft.Json</code> and manually) and sends the JSON to Apple:</li> </ul> <p><code>var json = "{ 'receipt-data': '" + receipt + "'}";</code></p> <p>OR:</p> <p><code>var json = new JObject(new JProperty("receipt-data", receipt)).ToString();</code></p> <p>and then:</p> <pre><code>var webRequest = System.Net.HttpWebRequest.Create("https://sandbox.itunes.apple.com/verifyReceipt"); webRequest.ContentType = "text/plain"; webRequest.Method = "POST"; byte[] byteArray = Encoding.UTF8.GetBytes(receipt); webRequest.ContentLength = byteArray.Length; using (var stream = webRequest.GetRequestStream()) { stream.Write(byteArray, 0, byteArray.Length); stream.Flush(); } var resp = webRequest.GetResponse(); if (resp != null) { using (var sr = new System.IO.StreamReader(resp.GetResponseStream())) { var result = sr.ReadToEnd().Trim(); var iapResponse = Newtonsoft.Json.JsonConvert.DeserializeObject&lt;AppleIapResponse&gt;(result); // always getting '21002' 'java.lang.NullPointerException' } } </code></pre> <p>I tried everything: changing the ContentType, the JSON formatting, the encoding....</p> <p>Any hints?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload