private static async Task <UserResetJob> SubmitJobAsync(string sandbox, string scid, string xuid)
        {
            var job = new UserResetJob {
                Sandbox = sandbox, Scid = scid
            };

            using (var submitRequest = new XboxLiveHttpRequest(true, scid, sandbox))
            {
                var response = await submitRequest.SendAsync(() =>
                {
                    var requestMsg     = new HttpRequestMessage(HttpMethod.Post, new Uri(baseUri, "submitJob"));
                    var requestContent = JsonConvert.SerializeObject(new JobSubmitReqeust(scid, xuid));
                    requestMsg.Content = new StringContent(requestContent);
                    requestMsg.Headers.Add("x-xbl-contract-version", "100");

                    return(requestMsg);
                });

                response.Response.EnsureSuccessStatusCode();

                // remove "" if found one.
                string responseContent = await response.Response.Content.ReadAsStringAsync();

                job.JobId         = responseContent.Trim(new char[] { '\\', '\"' });
                job.CorrelationId = response.CorrelationId;

                Log.WriteLog($"Submitting delete job for scid:{scid}, user:{xuid}, sandbox:{sandbox} succeeded. Jobid: {job.JobId}");
            }

            return(job);
        }
        private static async Task <JobStatusResponse> CheckJobStatus(UserResetJob userResetJob)
        {
            using (var submitRequest = new XboxLiveHttpRequest(true, userResetJob.Scid, userResetJob.Sandbox))
            {
                XboxLiveHttpResponse xblResponse = await submitRequest.SendAsync(() =>
                {
                    var requestMsg = new HttpRequestMessage(HttpMethod.Get, new Uri(baseUri, "jobs/" + userResetJob.JobId));
                    if (!string.IsNullOrEmpty(userResetJob.CorrelationId))
                    {
                        requestMsg.Headers.Add("X-XblCorrelationId", userResetJob.CorrelationId);
                    }
                    requestMsg.Headers.Add("x-xbl-contract-version", "100");

                    return(requestMsg);
                });

                // There is a chance if polling too early for job status, it will return 400.
                // We threat it as job queue and wait for next poll.
                if (xblResponse.Response.StatusCode == System.Net.HttpStatusCode.BadRequest)
                {
                    return(new JobStatusResponse
                    {
                        Status = "Queued",
                        JobId = userResetJob.JobId
                    });
                }

                // Throw HttpRequestExcetpion for other HTTP status code
                xblResponse.Response.EnsureSuccessStatusCode();

                string responseConent = await xblResponse.Response.Content.ReadAsStringAsync();

                var jobstatus = JsonConvert.DeserializeObject <JobStatusResponse>(responseConent);

                Log.WriteLog($"Checking {userResetJob.JobId} job stauts: {jobstatus.Status}");

                return(jobstatus);
            }
        }