Skip to content

Commit f83c734

Browse files
rez1-devpwnyyGoWMan813
authored
fix(docs): remove mixed lists to render code-blocks and correct numbering (#332)
* fix(docs): remove mixed lists to render code-blocks and correct numbering * Quick format in response handling --------- Co-authored-by: pwnyy <hubertytom@hotmail.com> Co-authored-by: GoWMan813 <33267417+GoWMan813@users.noreply.github.com>
1 parent b026a52 commit f83c734

1 file changed

Lines changed: 24 additions & 20 deletions

File tree

streamerbot/1.get-started/5.examples/http-post.md

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,22 @@ Read more about the `Execute C# Code` sub-action
2727

2828
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.
2929

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.
3131

3232
## Instructions
3333

3434
1. Setup the HTTPClient
3535

36-
```cs [Basic Setup]
37-
using System;
36+
```cs [Basic Setup]
37+
using System;
3838
using System.Text;
39-
using System.Threading.Tasks;
40-
using System.Net.Http;
41-
using System.Net.Http.Headers;
42-
using Newtonsoft.Json;
43-
using Newtonsoft.Json.Linq;
39+
using System.Threading.Tasks;
40+
using System.Net.Http;
41+
using System.Net.Http.Headers;
42+
using Newtonsoft.Json;
43+
using Newtonsoft.Json.Linq;
4444

45-
public class CPHInline {
45+
public class CPHInline {
4646
// You can set the timeout to any length you need
4747
private static readonly HttpClient _httpClient = new HttpClient{Timeout = TimeSpan.FromSeconds(30)};
4848

@@ -69,9 +69,9 @@ Read more about the `Execute C# Code` sub-action
6969

7070
2. Setup the sending of your payload
7171

72-
- We are going to send a `%userName%` and `%userId%` pair (from common triggers) as `PUT` request to our fictional logging website.
72+
We are going to send a `%userName%` and `%userId%` pair (from common triggers) as `PUT` request to our fictional logging website.
7373

74-
```cs [Send PUT payload in Execute method]
74+
```cs [Send PUT payload in Execute method]
7575
public bool Execute() {
7676
// Get the arguments - or abort if it does not exist
7777
if(!CPH.TryGetArg("userName", out string userName)) return false;
@@ -103,7 +103,7 @@ Read more about the `Execute C# Code` sub-action
103103

104104
3. The PATCH request
105105

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.
107107

108108
```cs [PATCH workaround]
109109
// ...
@@ -119,10 +119,11 @@ Read more about the `Execute C# Code` sub-action
119119

120120
4. Additional Headers
121121

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`.
124125

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.
126127

127128
```cs [Header management]
128129
public bool Execute() {
@@ -149,9 +150,11 @@ Read more about the `Execute C# Code` sub-action
149150

150151
5. Handling the response
151152

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.
155158

156159
```cs [Response handling]
157160
public bool Execute() {
@@ -187,5 +190,6 @@ Read more about the `Execute C# Code` sub-action
187190

188191
## Tips & Tricks
189192

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

Comments
 (0)