Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working for requests Content-Type is application/xml #37

Open
reinaldorossetti opened this issue Feb 9, 2022 · 4 comments
Open
Assignees
Labels
question Further information is requested

Comments

@reinaldorossetti
Copy link

ERRO[0007] TypeError: Cannot read property 'RequestTransactionPOSRegistration' of undefined

var jsonObject = xml2Json(pm.response.text());
pm.environment.set(
"pdc",
jsonObject.RequestTransactionPOSRegistration.POSs.POS.Identifier
);

Does not recognize as object.

@thim81
Copy link
Collaborator

thim81 commented Feb 10, 2022

hi @reinaldorossetti

Could you share your Postman collection and postman-to-k6 configuration? That way we can use it to reproduce the faulty behaviour, which will allow us to debug & potentially fix it.

@reinaldorossetti
Copy link
Author

Sorry, my script only work in my company vpn. I can try to find a public api, to try to simulate.

@reinaldorossetti
Copy link
Author

reinaldorossetti commented Feb 14, 2022

The problem is in xml parse, the same broken:

var jsonObject = xml2Json('<RequestTransactionPOSRegistration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.43"><authentication><login>xxx</login><password /><externalLoginName /></authentication><POSs><POS><TaxId>03.361.770/0001-58</TaxId><TipoPdC>LibC</TipoPdC><Ambiente>PRD</Ambiente><ExternalId>1234</ExternalId><Identifier>1234</Identifier><Description>MASSA ROBO</Description><Status>1</Status><POSType>LibC</POSType><POSApplication /><POSApplicationVersion /><RoutingProfile>undefined</RoutingProfile><CardEntryModes><CardEntryMode>01</CardEntryMode></CardEntryModes><CardEntryModes><CardEntryMode>02</CardEntryMode></CardEntryModes><CommGroup>1136</CommGroup><CardTypes><CardType>01</CardType></CardTypes><CardTypes><CardType>02</CardType></CardTypes><InstallmentPlans><InstallmentPlan>1</InstallmentPlan></InstallmentPlans><Unattended>FALSE</Unattended><FiscalPrinter>TRUE</FiscalPrinter><Printer>TRUE</Printer><Automation>TRUE</Automation><PINPad>TRUE</PINPad><PINPadIdleMsgLine1>QA TESTE</PINPadIdleMsgLine1><PINPadIdleMsgLine2>QA TESTE</PINPadIdleMsgLine2></POS></POSs><Error><Number /><Description /></Error></RequestTransactionPOSRegistration> ');

@thim81 thim81 self-assigned this Aug 9, 2022
@thim81
Copy link
Collaborator

thim81 commented Aug 10, 2022

hi @reinaldorossetti

Not sure what is broken, since I was able to properly parse the XML example you shared.

const xml = '<RequestTransactionPOSRegistration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.43"><authentication><login>xxx</login><password /><externalLoginName /></authentication><POSs><POS><TaxId>03.361.770/0001-58</TaxId><TipoPdC>LibC</TipoPdC><Ambiente>PRD</Ambiente><ExternalId>1234</ExternalId><Identifier>1234</Identifier><Description>MASSA ROBO</Description><Status>1</Status><POSType>LibC</POSType><POSApplication /><POSApplicationVersion /><RoutingProfile>undefined</RoutingProfile><CardEntryModes><CardEntryMode>01</CardEntryMode></CardEntryModes><CardEntryModes><CardEntryMode>02</CardEntryMode></CardEntryModes><CommGroup>1136</CommGroup><CardTypes><CardType>01</CardType></CardTypes><CardTypes><CardType>02</CardType></CardTypes><InstallmentPlans><InstallmentPlan>1</InstallmentPlan></InstallmentPlans><Unattended>FALSE</Unattended><FiscalPrinter>TRUE</FiscalPrinter><Printer>TRUE</Printer><Automation>TRUE</Automation><PINPad>TRUE</PINPad><PINPadIdleMsgLine1>QA TESTE</PINPadIdleMsgLine1><PINPadIdleMsgLine2>QA TESTE</PINPadIdleMsgLine2></POS></POSs><Error><Number /><Description /></Error></RequestTransactionPOSRegistration>';
const json = xml2Json(xml);
console.log(JSON.stringify(json, null, 2));

The result:

{
  "RequestTransactionPOSRegistration": {
    "$": {
      "xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
      "xmlns:xsd": "http://www.w3.org/2001/XMLSchema",
      "version": "1.43"
    },
    "authentication": [
      {
        "login": [
          "xxx"
        ],
        "password": [
          ""
        ],
        "externalLoginName": [
          ""
        ]
      }
    ],
    "POSs": [
      {
        "POS": [
          {
            "TaxId": [
              "03.361.770/0001-58"
            ],
            "TipoPdC": [
              "LibC"
            ],
            "Ambiente": [
              "PRD"
            ],
            "ExternalId": [
              "1234"
            ],
            "Identifier": [
              "1234"
            ],
            "Description": [
              "MASSA ROBO"
            ],
            "Status": [
              "1"
            ],
            "POSType": [
              "LibC"
            ],
            "POSApplication": [
              ""
            ],
            "POSApplicationVersion": [
              ""
            ],
            "RoutingProfile": [
              "undefined"
            ],
            "CardEntryModes": [
              {
                "CardEntryMode": [
                  "01"
                ]
              },
              {
                "CardEntryMode": [
                  "02"
                ]
              }
            ],
            "CommGroup": [
              "1136"
            ],
            "CardTypes": [
              {
                "CardType": [
                  "01"
                ]
              },
              {
                "CardType": [
                  "02"
                ]
              }
            ],
            "InstallmentPlans": [
              {
                "InstallmentPlan": [
                  "1"
                ]
              }
            ],
            "Unattended": [
              "FALSE"
            ],
            "FiscalPrinter": [
              "TRUE"
            ],
            "Printer": [
              "TRUE"
            ],
            "Automation": [
              "TRUE"
            ],
            "PINPad": [
              "TRUE"
            ],
            "PINPadIdleMsgLine1": [
              "QA TESTE"
            ],
            "PINPadIdleMsgLine2": [
              "QA TESTE"
            ]
          }
        ]
      }
    ],
    "Error": [
      {
        "Number": [
          ""
        ],
        "Description": [
          ""
        ]
      }
    ]
  }
}

@thim81 thim81 added the question Further information is requested label Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants