Skip to content

Commit 08aba57

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 08aba57

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

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)