Exchange Model & Variable Detection
When an exchange is added to a API Parrot collection, it will be parsed and a model will be created for that exchange. The goal of this parser is to figure how the request and the response are structured so that:
- The request can be reconstructed with slight modifications in the request data.
- The response can be systematically analyzed to extract variables and other useful information.
Viewing the Exchange Model
The exchange model can be viewed in exchange properties panel of a given exchange.
In the example above can we see how the parser has:
- Identified the URL from the HTTP request.
- Extracted the pathname from the URL.
- Identified the different subpaths in the pathname.
Variable Detection
Any one of these nodes in the tree created by the parser is compared to every other node in every other exchange in the given function or collection. If a match is found between a node in the response side of an eariler exchange and a node in the request side of a later exchange, a variable is created.
This algoritm is what allows API Parrot to automatically detect variables and other useful information.
Node Types
The parser will create a tree of nodes for each exchange, this is the exchange model. There are different types of nodes that can be created by the parser, each will break down the data in a different way. The parser will automatically detect the type of node that is most suitable for the data it is parsing.
The nodes currently supported by the parser are:
- String
- Number
- Boolean
- Null
- Base64
- JSON Parse
- JSON Array
- JSON Object
- Hex
- URI Params
- URI Encoded
- URI Path
- URL
- Relative URL
- XML Parse
- XML Element
- XML Text
- JavaScript
- Basic Auth
- Bearer Auth
- Set Cookie Header
- Cookie Header
- Location Header
- HTTP Request
- HTTP Response
- HTTP Headers
- HTTP Exchange
Troubleshooting
If a correlation is not detected, it is often because the data is not structured in a way that the parser can understand. In these cases, you can manually add that variable later on after you have exported the function to code. If you have suggestions for improvements to the parser, please let us know by creating an issue on our GitHub page.