Skip to content

Commit 6b742d6

Browse files
KyrillosNagehKyrillos Nageh Abdelnour Flamon
andauthored
Add detailed examples for setPathParameters with Map and values (#260)
* Add detailed examples for setPathParameters with Map and values * Add detailed examples for setPathParameters with Map and values --------- Co-authored-by: Kyrillos Nageh Abdelnour Flamon <[email protected]>
1 parent e84c7bb commit 6b742d6

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

docs/Keywords/API/Request_Builder.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,31 @@ SHAFT.API api = new SHAFT.API("serviceURI");
187187
List<List<Object>> parameters = Arrays.asList(Arrays.asList("search", "john"), Arrays.asList("orderBy","desc"));
188188
api.get("serviceName").setParameters(parameters, RestActions.ParametersType.QUERY).perform();
189189
```
190+
### Set Path Parameters
191+
192+
Sets the path parameters dynamically by replacing placeholders in the `serviceName`.
193+
194+
This method supports two modes:
195+
1. **Key-Value Replacement**: Use a `Map<String, Object>` to specify placeholders and their corresponding values.
196+
2. **Ordered Value Replacement**: Provide values in the exact order the placeholders appear in the `serviceName`.
197+
198+
#### Key-Value Replacement
199+
Pass a `Map` of key-value pairs to replace placeholders by their names:
200+
```java
201+
Map<String, Object> pathParams = Map.of("PostID", 1, "CommentID", 1);
202+
SHAFT.API api = new SHAFT.API("https://jsonplaceholder.typicode.com");
203+
api.get("/posts/{PostID}/comments/{CommentID}")
204+
.setPathParameters(pathParams)
205+
.perform();
206+
```
207+
#### Ordered Value Replacement
208+
Pass value directly to replace placeholder in the `serviceName`:
209+
```java
210+
SHAFT.API api = new SHAFT.API("https://jsonplaceholder.typicode.com");
211+
api.get("/posts/{PostID}/comments/{CommentID}")
212+
.setPathParameters("1", "1")
213+
.perform();
214+
```
190215

191216
### Set URL Arguments
192217
Sets the url arguments (if any) for the API request that you're currently building.

0 commit comments

Comments
 (0)