Skip to content

Commit 3aacc11

Browse files
authored
Merge pull request #78 from umbraco/bugfix/connect-to-dynamics
Handling HTTP exceptions
2 parents 2750ee9 + 45f2b64 commit 3aacc11

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/Umbraco.Cms.Integrations.Crm.Dynamics/Controllers/FormsController.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public async Task<string> GetAccessToken([FromBody] OAuthRequestDto authRequestD
9393
{ "grant_type", "authorization_code" },
9494
{ "client_id", AuthorizationService.ClientId },
9595
{ "redirect_uri", AuthorizationService.RedirectUri },
96-
{ "code", authRequestDto.Code }
96+
{ "code", authRequestDto.Code }
9797
};
9898

9999
var requestMessage = new HttpRequestMessage
@@ -119,17 +119,11 @@ public async Task<string> GetAccessToken([FromBody] OAuthRequestDto authRequestD
119119
return "Error: " + identity.Error.Message;
120120

121121
return result;
122-
}
123122

124-
if (response.StatusCode == HttpStatusCode.BadRequest)
125-
{
126-
var errorResult = await response.Content.ReadAsStringAsync();
127-
var errorDto = JsonConvert.DeserializeObject<ErrorDto>(errorResult);
128-
129-
return "Error: " + errorDto.ErrorDescription;
130-
}
123+
var errorResult = await response.Content.ReadAsStringAsync();
124+
var errorDto = JsonConvert.DeserializeObject<ErrorDto>(errorResult);
131125

132-
return "Error: An unexpected error occurred.";
126+
return "Error: " + errorDto.ErrorDescription;
133127
}
134128

135129
[HttpGet]

0 commit comments

Comments
 (0)