Skip to content

Commit d4913d2

Browse files
committed
fix QuestionFlow
1 parent 73439c2 commit d4913d2

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

MojangAPI/HttpAction/HttpActionClient.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ HttpResponseMessage response
6666

6767
return result;
6868
}
69+
catch (ArgumentException)
70+
{
71+
throw;
72+
}
6973
catch (Exception ex)
7074
{
7175
if (httpAction.ErrorHandler != null)

MojangAPI/SecurityQuestion/QuestionFlow.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ public Task<MojangAPIResponse> CheckTrusted(string accessToken) =>
3333

3434
RequestHeaders = new HttpHeaderCollection
3535
{
36-
{ "Authorization", "Bearer " + accessToken ?? throw new ArgumentNullException() }
36+
{ "Authorization", "Bearer " + accessToken ?? throw new ArgumentNullException(nameof(accessToken)) }
3737
},
3838

3939
ResponseHandler = HttpResponseHandlers.GetSuccessCodeResponseHandler(new MojangAPIResponse()),
40-
ErrorHandler = null
40+
ErrorHandler = HttpResponseHandlers.GetJsonErrorHandler<MojangAPIResponse>()
4141
});
4242

4343
public Task<QuestionFlowResponse> GetQuestionList(string accessToken) =>
@@ -68,7 +68,7 @@ public Task<QuestionFlowResponse> GetQuestionList(string accessToken) =>
6868

6969
return new QuestionFlowResponse(new QuestionList(questions.ToArray()));
7070
},
71-
ErrorHandler = null
71+
ErrorHandler = HttpResponseHandlers.GetJsonErrorHandler<QuestionFlowResponse>()
7272
});
7373

7474
public Task<MojangAPIResponse> SendAnswers(QuestionList list, string accessToken)
@@ -85,11 +85,11 @@ public Task<MojangAPIResponse> SendAnswers(QuestionList list, string accessToken
8585
JArray jarr = new JArray();
8686
foreach (var item in list)
8787
{
88-
jarr.Add(new
88+
jarr.Add(JObject.FromObject(new
8989
{
9090
id = item.AnswerId,
9191
answer = item.Answer
92-
});
92+
}));
9393
}
9494

9595
return client.SendActionAsync(new HttpAction<MojangAPIResponse>
@@ -103,10 +103,10 @@ public Task<MojangAPIResponse> SendAnswers(QuestionList list, string accessToken
103103
{ "Authorization", "Bearer " + accessToken }
104104
},
105105

106-
Content = new StringContent(jarr.ToString()),
106+
Content = new StringContent(jarr.ToString(), Encoding.UTF8, "application/json"),
107107

108108
ResponseHandler = HttpResponseHandlers.GetSuccessCodeResponseHandler(new MojangAPIResponse()),
109-
ErrorHandler = null
109+
ErrorHandler = HttpResponseHandlers.GetJsonErrorHandler<MojangAPIResponse>()
110110
});
111111
}
112112
}

0 commit comments

Comments
 (0)