Skip to content

How to assign a collection variable using portman #362

Answered by thim81
shubhambajad asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @shubhambajad

Typically you would do something like this in your Portman config:

{
  "version": 1,
  "assignVariables": [
    {
      "openApiOperation": "POST::*",
      "collectionVariables": [
        {
          "openApiOperationId": "get-messages",
          "collectionVariables": [
            {
              "responseBodyProp": "[0].id",
              "name": "message_id"
            }
          ]
        }
      ]
    }
  ]
}

Where the target is "responseBodyProp": "[0].id" which means take the 1st item from the array in the response body, and from the item take the property id.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by shubhambajad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants