Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending json with tsung POST request

I'm trying to create a POST request with Tsung

<request> 
  <http url="api.whatever.com" method="POST" version="1.1" contents=""></http>
</request>

How can I send a JSON document in the contents attribute?

contents='{"name": "alex"}' 

is of course invalid...

Is there a way I can send JSON with my POST request?

like image 899
Alex Avatar asked May 08 '14 12:05

Alex


People also ask

Can we send JSON object in post request?

To post JSON to a REST API endpoint, you must send an HTTP POST request to the REST API server and provide JSON data in the body of the POST message. You also need to specify the data type in the body of the POST message using the Content-Type: application/json request header.


1 Answers

I was able to do this by replacing " &quot; and adding the content type header application/json

So my example would become:

content_type='application/json' contents='{&quot;name&quot;: &quot;alex&quot;}
like image 178
Alex Avatar answered Oct 03 '22 07:10

Alex