Reputation: 447
I have to do load test for PUT(REST service) request which uploads a file.
I'm able to consume successfully from Advanced Rest Client with the following info:
Service:
PUT http://localhost:8080/home/cmistest/app/documentservices/rest/nodes/upload/12178
Headers:
Content-Type: multipart/form-data, Accept: application/json
Response:
{
"UploadContentResponse": {
"Id": 12179,
"ContentUrl": "http://localhost:8080/home/cmistest/app/documentservices/rest/nodes/12179/content"
}
}
I'm unable to use PUT from JMeter.
I can see JMeter File Upload with HTTP Put Method Not Working But not sure which headers needs to be set.
Upvotes: 1
Views: 2757
Reputation: 417
First, I'd start by reviewing Testing SOAP/REST Web Services Using JMeter This company's site has proven quite valuable to me.
At the Test Plan level add the following Configuration Element:
HTTP Request Defaults
Web Server Name: localhost
Port Number: 8080
Protocol: http
Content Encoding: utf8
Within the Thread Group, add this Configuration Element:
HTTP Header Manager
Name: Content-Type
Value: application/json
Now if you're actually creating the json data that you're passing, I'd parameterize it via a RegEx, which can then be used in the PUT request.
CREATE HTTP Request
Method: POST
Path: /home/cmistest/app/documentservices/rest/nodes/create/12178
Use multipart/form-data for POST: enabled
Body Data:
{
"id": 0,
"name": "Star Lord",
"address": "123 Milky Way",
}
Regular Expression Extractor
Name: newWhateverId
Apply To: Main Sample Only
Field to check: Body
Reference Name: newWhateverId
Regular Expression: \,"Id":(.+?)\,
Template: $1$
Match No.: 1
Default Value: NONE
Regular Expression Extractor
Name: newWhateverBody
Apply To: Main Sample Only
Field to check: Body
Reference Name: newWhateverBody
Regular Expression: (?s)(^.*)
Template: $1$
Match No.: 1
Default Value: NONE
Then in the PUT HTTP Request you can just pass in the values:
PUT HTTP Request
Method: PUT
Path: /home/cmistest/app/documentservices/rest/nodes/upload/${newWhateverId}
Body Data:
{
${newWhateverBody}
}
Upvotes: 1