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()
45
45
}
46
46
47
47
[ HttpPost ]
48
- public string Add ( [ FromBody ] ContentConfigDto dto )
48
+ public async Task < string > Add ( [ FromBody ] ContentConfigDto dto )
49
49
{
50
50
var result = _zapConfigService . Add ( dto ) ;
51
51
if ( ! string . IsNullOrEmpty ( result ) ) return result ;
52
52
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 } } ) ;
61
55
}
62
56
63
57
[ HttpGet ]
Original file line number Diff line number Diff line change @@ -15,9 +15,20 @@ public class ZapierService
15
15
16
16
public async Task < string > TriggerAsync ( string requestUri , Dictionary < string , string > content )
17
17
{
18
- var result = await ClientFactory ( ) . PostAsync ( requestUri , new FormUrlEncodedContent ( content ) ) ;
18
+ try
19
+ {
20
+ var result = await ClientFactory ( ) . PostAsync ( requestUri , new FormUrlEncodedContent ( content ) ) ;
19
21
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
+ }
21
32
}
22
33
}
23
34
}
You can’t perform that action at this time.
0 commit comments