Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify nested json body in POST request

I'm trying to set Artillery config to be able to send nested JSON body. This is how my configuration looks like:

config:
  target: <URL>
  phases:
    - duration: 10
      arrivalRate: 20
  processor: "./input-parser.js"
scenarios:
  - flow:
    - function: "parseJsonFile"
    - post:
        url: /workflow-instance
        headers:
           Content-Type: "application/json"
        json:
          name: "{{ name }}"
          namespace: "{{ namespace }}"
          template_name: "{{ template_name }}"
          attributes: "{{ attributes }}"
    - get:
        url: "/workflow-instance/status?name={{ template_name }}&namespace={{ namespace }}"

I have a problem with "attributes" because the content of attributes is:

{ pod_name: 'POD_NAME', port: 'PORT_NUMBER' }

So basically, this will not work:

attributes: "{ pod_name: 'POD_NAME', port: 'PORT_NUMBER' }"

as well as this:

attributes:
  pod_name: 'POD_NAME'
  port: 'PORT_NUMBER'

I didn't found good examples for this particular case in Artillery docs.

like image 724
Bakir Jusufbegovic Avatar asked Apr 11 '26 17:04

Bakir Jusufbegovic


1 Answers

The following workaround worked for me Embedding JSON Data into YAML file

Then you'd have to change your attributes for:

attributes: '{ pod_name: "POD_NAME", port: "PORT_NUMBER" }'

I'm using:

Artillery: 1.7.9
Artillery Pro: not installed (https://artillery.io/pro)
Node.js: v14.6.0
OS: darwin/x64
like image 114
jmartori Avatar answered Apr 17 '26 23:04

jmartori



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!