You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: streamerbot/1.get-started/5.examples/http-post.md
+24-20Lines changed: 24 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,22 +27,22 @@ Read more about the `Execute C# Code` sub-action
27
27
28
28
Be it a single use `Execute C# Code` block for a single instance of needing to send a request, or a more persistent C# module with different actions triggering different `Execute C# Method` sub-actions - you need to know how use this feature in your normal action flow.
29
29
30
-
-The following tutorial will only focus on the magic happening inside of the C# code module.
30
+
The following tutorial will only focus on the magic happening inside of the C# code module.
@@ -103,7 +103,7 @@ Read more about the `Execute C# Code` sub-action
103
103
104
104
3. The PATCH request
105
105
106
-
-Specifically the built-in handling for the `PATCH` request type may not be available in the .net versions used by StreamerBot. In this case, you need a workaround.
106
+
Specifically the built-in handling for the `PATCH` request type may not be available in the .net versions used by StreamerBot. In this case, you need a workaround.
107
107
108
108
```cs [PATCH workaround]
109
109
// ...
@@ -119,10 +119,11 @@ Read more about the `Execute C# Code` sub-action
119
119
120
120
4. Additional Headers
121
121
122
-
- If you need to additionally include specific headers - like submitting an authorization token for the Twitch API or Discord API - make sure to clear and set the headers on each call you make.
123
-
1. You can also send individual headers with each request itself, but that requires you to always use the `SendAsync` method and building your own `HttpRequestMessage`.
122
+
If you need to additionally include specific headers - like submitting an authorization token for the Twitch API or Discord API - make sure to clear and set the headers on each call you make.
123
+
124
+
You can also send individual headers with each request itself, but that requires you to always use the `SendAsync` method and building your own `HttpRequestMessage`.
124
125
125
-
-If your code only does a static request whose headers never change, resetting the headers is **not strictly necessary**. But it's good practice to not forget later when you need it.
126
+
If your code only does a static request whose headers never change, resetting the headers is **not strictly necessary**. But it's good practice to not forget later when you need it.
126
127
127
128
```cs [Header management]
128
129
publicboolExecute() {
@@ -149,9 +150,11 @@ Read more about the `Execute C# Code` sub-action
149
150
150
151
5. Handling the response
151
152
152
-
- Since you have to do the entire request handling yourself, that includes handling the response.
153
-
1. If you don't need to know what the server responded, you can ignore it like in the examples above.
154
-
2. If you need to know if the request succeeded or are expecting data in return, follow the below example.
153
+
Since you have to do the entire request handling yourself, that includes handling the response.
154
+
155
+
- If you don't need to know what the server responded, you can ignore it like in the examples above.
156
+
157
+
- If you need to know if the request succeeded or are expecting data in return, follow the below example.
155
158
156
159
```cs [Response handling]
157
160
publicboolExecute() {
@@ -187,5 +190,6 @@ Read more about the `Execute C# Code` sub-action
187
190
188
191
## Tips & Tricks
189
192
190
-
- Wrapping sensitive parts of code, especially when using web requests, into `try``catch` blocks is good practice and prevents potential unexpected bigger issues you do not anticipate.
191
-
1. Of course, proper error handling is always better, but not always necessary.
193
+
Wrapping sensitive parts of code, especially when using web requests, into `try``catch` blocks is good practice and prevents potential unexpected bigger issues you do not anticipate.
194
+
195
+
Of course, proper error handling is always better, but not always necessary.
0 commit comments