File tree Expand file tree Collapse file tree 2 files changed +16
-11
lines changed
src/Umbraco.Cms.Integrations.Automation.Zapier Expand file tree Collapse file tree 2 files changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -45,19 +45,13 @@ public IEnumerable<ContentTypeDto> GetContentTypes()
4545 }
4646
4747 [ HttpPost ]
48- public string Add ( [ FromBody ] ContentConfigDto dto )
48+ public async Task < string > Add ( [ FromBody ] ContentConfigDto dto )
4949 {
5050 var result = _zapConfigService . Add ( dto ) ;
5151 if ( ! string . IsNullOrEmpty ( result ) ) return result ;
5252
53- var t = Task . Run ( async ( ) => await _zapierService . TriggerAsync ( dto . WebHookUrl ,
54- new Dictionary < string , string > { { Constants . Content . Name , dto . ContentTypeName } } ) ) ;
55-
56- result = t . Result ;
57-
58- if ( ! string . IsNullOrEmpty ( result ) ) return result ;
59-
60- return result ;
53+ return await _zapierService . TriggerAsync ( dto . WebHookUrl ,
54+ new Dictionary < string , string > { { Constants . Content . Name , dto . ContentTypeName } } ) ;
6155 }
6256
6357 [ HttpGet ]
Original file line number Diff line number Diff line change @@ -15,9 +15,20 @@ public class ZapierService
1515
1616 public async Task < string > TriggerAsync ( string requestUri , Dictionary < string , string > content )
1717 {
18- var result = await ClientFactory ( ) . PostAsync ( requestUri , new FormUrlEncodedContent ( content ) ) ;
18+ try
19+ {
20+ var result = await ClientFactory ( ) . PostAsync ( requestUri , new FormUrlEncodedContent ( content ) ) ;
1921
20- return result . IsSuccessStatusCode ? string . Empty : result . ReasonPhrase ;
22+ return result . IsSuccessStatusCode ? string . Empty : result . ReasonPhrase ;
23+ }
24+ catch ( HttpRequestException )
25+ {
26+ return "Could not access the requested URL: " + requestUri ;
27+ }
28+ catch ( Exception )
29+ {
30+ throw ;
31+ }
2132 }
2233 }
2334}
You can’t perform that action at this time.
0 commit comments