bruno icon indicating copy to clipboard operation
bruno copied to clipboard

Incorrect JSON response from XML body request

Open jjaimes opened this issue 1 year ago • 1 comments

I have checked the following:

  • [X] I use the newest version of bruno.
  • [X] I've searched existing issues and found nothing related to my issue.

Describe the bug

INPUT: this xml body:

<?xml version='1.0' encoding='UTF-8'?>
<MT_Customer>
    <row>
        <CustomerID>DJAIMES</CustomerID>
        <Country>Venezuela</Country>
    </row>
    <row>
        <CustomerID>JJAIMES</CustomerID>
        <Country>Chile</Country>
    </row>
</MT_Customer>

INCORRECT RESPONSE:

{
  "row": {
    "CustomerID": "JJAIMES",
    "Country": "Chile"
  }
}

CORRECT RESPONSE MUST BE:

{
  "row": {
    "CustomerID": "DJAIMES",
    "Country": "Venezuela"
  },
  "row": {
    "CustomerID": "JJAIMES",
    "Country": "Chile"
  }
}

.bru file to reproduce the bug

meta {
  name: 02-Convert_XML_to_JSON
  type: http
  seq: 3
}

get {
  url: https://{{sap_url}}/http/convert_xml_to_json
  body: xml
  auth: basic
}

headers {
  Content-Type: application/xml
}

auth:basic {
  username: {{clientId}}
  password: {{clientSecret}}
}

body:xml {
  <?xml version='1.0' encoding='UTF-8'?>
  <MT_Customer>
      <row>
          <CustomerID>DJAIMES</CustomerID>
          <Country>Venezuela</Country>
      </row>
      <row>
          <CustomerID>JJAIMES</CustomerID>
          <Country>Chile</Country>
      </row>
  </MT_Customer>
}

Screenshots/Live demo link

The RESPONSE (file: 01_incorrect_response_bruno.jpeg) has been compared with 2 tools:

  1. Visual Studio Code (Rest client) - (file: 01_correct_response_VSC.jpeg)
  2. APIDOG (file: 01_correct_response_APIDOG.jpeg)

(I hate POSTMAN 😁)

BRUNO RESPONSE (INCORRECT response) 01_incorrect_response_bruno

VISUAL STUDIO CODE RESPONSE (CORRECT response) 01_correct_response_VSC

APIDOG RESPONSE (CORRECT response) 01_correct_response_APIDOG

jjaimes avatar May 12 '24 13:05 jjaimes

Bruno will automatically parse JSON in response. Because of this duplicate keys are removed.

We probably need to add a raw response viewer.

Its-treason avatar May 12 '24 14:05 Its-treason