Venkat Matta

it's all about the Performance Testing

REST WS By Jmeter

Representational State Transfer (REST) uses the HTTP request method, and the most popular  are GET, POST, PUT and DELETE. Responses to these requests return status codes indicating success or failure as well as any applicable headers, and JSON representing the affected fields (or nothing) in the message body. The following sections describe how you can easily write a JMeter script with one of these methods.

GET REQUEST METHOD

1. Add an HTTP Request to your Thread Group.
2. Fill in the Server Name or IP, path, and choose GET method.
    For example, we use maps.googleapis.com as Server Name and ‘/maps/api/geocode/xml’ as path
3. If your API request contain query parameters, you may specify it in path (for example, ‘/?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false’) or in Parameters area:
Name: Address,Value: 1600+Amphitheatre+Parkway,+Mountain+View
Name:sensor,Value:false
Jmeter_Rest
4. Add View Results Tree, and run your script.

POST REQUEST METHOD

In POST requests, you can fill in both the body and the headers. You can also specify query parameters in path. The HTTP headers, which contain metadata, are tightly defined by the HTTP spec. They can only contain plain text and must be formatted in a certain manner. To specify headers, you’ll need the HTTP Header Manager, and the most common headers are Content-Type and Accept.

  • The Content-Type entity-header field indicates the media type of the entity-body sent to the recipient.
  • Accept can be used to specify certain media types that are acceptable for the response. You can use a user agent to simulate different browsers’ behaviors.

Post Body can be useful for the following requests: GWT RPC HTTP, JSON REST HTTP, XML REST HTTP, and SOAP HTTP Request.

For instance, we use the server name: localhost.8020

Path : /rest/management/profiles/Dev-SOAINTGR/testruns

Body : <testRun category=”performance” platform=”Windows” versionMajor=”5″ versionMinor=”1″ versionRevision=”1500″ versionBuild=”111″ />

Note:- replace the server name(URL), path and soap body with your required parameters

And header: Content-Type: text/xml

Refer below picture

Jmeter_Rest_Post

Now add the view results in tree listener and run your test.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Information

This entry was posted on March 29, 2016 by in Webservices.
%d bloggers like this: