一个 POST JSON 如何编码 tsung 中的内容?

How does one POST JSON encoded content in tsung?

这是我的:

 <session name="es_load" probability="100" type="ts_http">
         <request subst="true">
            <http url='/access.log' version='1.0'
              contents='{&quot;username&quot;=&quot;rsss&quot;,&quot;password&quot;=&quot;pass&quot;}'
            content_type='application/json' method='POST'>
            </http>
         </request>
  </session>

我什至没有看到它被发布到后端。

切换到 locust.io,再开心不过了!

<request>
  <http url="/portal/v2/portal" method="POST" version="1.1" contents='{
    "status": "online",
    "language": "en",
    "preference": {
      "optIn": "1"
    }
  }'>
    <http_header name="authorization" value="Bearer token"/>
  </http>
</request>

而不是 'contents' 属性使用“contents_from_file”属性,如下所示,

   <request subst="true">
     <http url="https://**API**" method="POST"
     **contents_from_file**="file.json">
                    
     <http_header name="accept" value="*/*"/>
     <http_header name="content-type" value="application/json"/>
     <http_header name="authorization" value="%%_token%%"/>
     
    </http>
   </request>

注意:在此'file.json'正确提供数据并保存。