Skip to main content

Variables Extraction

"Post-operation" supports adding the "extract variable" function, which can automatically extract data based on the results returned by the API and set it as a variable (temporary variable/environment variable/global variable), which is convenient for other APIs to use directly.

Set up Assertions

Open an API in Apidog, and clicking the" Extract Variable" in Post Processors.

API Pass Data to Each Other

For example, the current request parameters of API B depend on the data returned by API A, and it is now hoped that API B can automatically obtain the data returned by API A and use it as a request parameter while sending the request. The implementation idea is as follows:

  1. The A API adds the function of extracting variables in the post-operation to automatically extract the returned data into variables.

  2. The parameter value corresponding to the B API directly refers to the extracted variable.

Example A API

Open the Post Operations page for the A API use case and add the ability to extract variables in the Post Action. Extract the token value from the Response JSON data returned by token the API into a variable named .

Example B API

Write in the corresponding parameter value {{token}} , that is, reference token a variable that can be named .