diff --git a/src/pages/testing/script/_meta.js b/src/pages/testing/script/_meta.js index 036839db..b1d0b7dc 100644 --- a/src/pages/testing/script/_meta.js +++ b/src/pages/testing/script/_meta.js @@ -10,4 +10,5 @@ export default { "request": "Request", "response": "Response", "dynamic-variables": "Dynamic Variables", + "xml-example": "XML Example", } \ No newline at end of file diff --git a/src/pages/testing/script/xml-example.mdx b/src/pages/testing/script/xml-example.mdx new file mode 100644 index 00000000..d45a32d9 --- /dev/null +++ b/src/pages/testing/script/xml-example.mdx @@ -0,0 +1,33 @@ +import { Callout } from "nextra/components"; + +# Posting an XML body + +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. + +To enable file system access with bruno, you have to enable a setting within the collections `bruno.json` file: + +```json copy filename="bruno.json" +{ + "version": "1", + "name": "my-collection", + "type": "collection", + "scripts": { + "filesystemAccess": { + "allow": true + } + } +} +``` + +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: + +```js copy +const fs = require("fs"); +const path = require("path"); + +const attachmentFilename = "some.xml"; +const attachmentPath = path.join(bru.cwd(), attachmentFilename); +const attachment = fs.readFileSync(attachmentPath); + +req.setBody({"MyServiceXmlrequest": attachment.toString()}); +```