Skip to content

Commit 376ad0a

Browse files
committed
Add an example on how to post XML data that is pulled from an XMl file.
Signed-off-by: Tim Beermann <[email protected]>
1 parent 681e4af commit 376ad0a

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed

docs/table-of-contents.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Index
2+
3+
## Introduction
4+
5+
- [Manifesto](/manifesto)
6+
- [Support](/support)
7+
8+
## Bru Lang
9+
10+
- [Overview](/bru-lang-overview)
11+
- [Samples](/bru-language-samples)
12+
- [Language](/bru-language-design)
13+
- [Tag Reference](/bru-language-tag-reference)
14+
- [Syntax Highlighting](/bru-lang-extensions.md)
15+
16+
## Bru CLI
17+
18+
- [Overview](/cli/overview)
19+
20+
## Secrets Management
21+
- [Overview](/secrets-management/overview)
22+
- [DotEnv File](/secrets-management/dotenv-file)
23+
- [Secret Variables](/secrets-management/secret-variables)
24+
25+
## Scripting
26+
27+
- [Getting Started](/scripting/introduction)
28+
- [Vars](/scripting/vars)
29+
- [Response Query](/scripting/response-query)
30+
- [Inbuilt Libraries](/scripting/inbuilt-libraries)
31+
- [External Libraries](/scripting/external-libraries)
32+
- [Sync Requests](/scripting/sync-requests)
33+
- [JavaScript Reference](/scripting/javascript-reference)
34+
- [XML Post Example](/scripting/xml-example)
35+
36+
## Testing
37+
38+
- [Getting Started](/testing/introduction)
39+
- [Assertions](/testing/assertions)
40+
- [JavaScript Reference](/testing/javascript-reference)

src/pages/testing/script/_meta.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ export default {
1010
"request": "Request",
1111
"response": "Response",
1212
"dynamic-variables": "Dynamic Variables",
13+
"xml-example": "XML Example",
1314
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { Callout } from "nextra/components";
2+
3+
# Posting an XML body
4+
5+
If you are posting against XML APIs it might be easier for you to get the XML directly from an XML file instead of posting its content into the _Form URL Encoded_ fields.
6+
7+
To enable file system access with bruno, you have to enable a setting within the collections `bruno.json` file:
8+
9+
```json copy filename="bruno.json"
10+
{
11+
"version": "1",
12+
"name": "my-collection",
13+
"type": "collection",
14+
"scripts": {
15+
"filesystemAccess": {
16+
"allow": true
17+
}
18+
}
19+
}
20+
```
21+
22+
Besides that, just use a similar script like this one to pull data from your XML file that resides right next to your _.bru_ file:
23+
24+
```js copy
25+
const fs = require("fs");
26+
const path = require("path");
27+
28+
const attachmentFilename = "some.xml";
29+
const attachmentPath = path.join(bru.cwd(), attachmentFilename);
30+
const attachment = fs.readFileSync(attachmentPath);
31+
32+
req.setBody({"MyServiceXmlrequest": attachment.toString()});
33+
```

0 commit comments

Comments
 (0)