I have a JSON Response that is of the below format:
{
"success": true,
"data": {
"_id": 270582,
"_type": "Example",
"_tasklist": [{
"_id": "m1mv27r8upy2bta982jme3bp",
"writable": true
}]
}
}
I am trying to fetch the request Id (data._id) & task list id (data._tasklist[0]._id) in JMeter using JSON Extractor as below and use in the subsequent requests using ${instanceid} & ${taskid}
This is not successful. However if I try to fetch just the instance id, it does substitute the value for instance id in the following requests. I did try a few suggestions from the SO answers but they have not solved my issue. What am I doing wrong here? Please help.
OK, The issue was that the default values should have been specified.
I fixed it as below :
Checked the logs and there it showed what the issue was!
facepalm moment :(
Related
My current test suite requires me to send some HTTP POST requests to API, some of which require specific objects to be posted via HTTP Request. I encountered some problems when trying to fetch those object from my YAML file when running Jmeter in Taurus.
I will attach part of my YAML file here for context (had to delete of change some properties for confidentiality):
jmeter:
properties:
number.of.users: 1000
rampup.period: 300
loop.count: 1
client.id: "23id"
array.of.clients: ["id1","id2","id3"]
ids: [1,2,3]
rq:
- "number": "7312sa1"
"signed": "2020-06-08T00:00:00.000+0000"
"crmClientId": "1-32D1P"
The problem is: when I try to pass string properties to my HTTP Request like that:
{
"id": 1986,
"jsonrpc": "2.0",
"method": "method",
"params":
{
${__P(rq,)}
}
}
all properties are wrapped in single quotation marks which causes request to receive error 400 in return because request after acquiring property is looking like this:
{
"id": 1986,
"jsonrpc": "2.0",
"method": "method",
"params":
{
'rq':
'number': '7312sa1'
'signed': '2020-06-08T00:00:00.000+0000'
'crmClientId': '1-32D1P'
}
}
Is there a way to pass string properties to request with double quotation marks or structure my YAML file in a way, which will construct request according to this example:
{
"id": 1986,
"jsonrpc": "2.0",
"method": "method",
"params":
{
rq:
"number": "7312sa1"
"signed": "2020-06-08T00:00:00.000+0000"
"crmClientId": "1-32D1P"
}
}
I tried using groovy replaceAll() method but it doesn't work with complex objects. My only solution as of right now is running some sort of groovy script in setUp thread and then acquire them is HTTP request via groovy jmeter function
You're sending a string representation of Python's dictionary, you need to send it as a simple string.
Check out YAML Multiline Strings and choose the most convenient option for you.
Example usage:
modules:
jmeter:
properties:
rq: >
\n"number": "7312sa1"\n
"signed": "2020-06-08T00:00:00.000+0000"\n
"crmClientId": "1-32D1P"\n
Taurus is presumably built to make testers and/or devops lives easier, it doesn't seem that it's your case, perhaps you should consider switching to JMeter without any wrappers instead?
I am trying to do POST data and it's getting 200. but if in response JSON data has list [] like
{
"resno":"5600123",
"inquiry": [
{
"number": "1",
"organization": "",
"name": "Amarbold",
"collateralInfo2": "0",
"description": "dadtatadada"
},
{
"number": "1",
"organization": "",
"name": "Amarbold",
"collateralInfo2": "0",
"description": "dadtatadada"
}
]
}
this then i recieved this.
{"resno":"5600123","inquiry":null}
It's working fine in Postman.
how can i fix?
Given you send the same requests you should have the same responses, double check your request payload and headers using View Results Tree listener or maybe even better an external sniffer tool like Fiddler or Burp
Once you identify and eliminate the differences - you should get the same behaviour.
Be aware that it's also possible to record the Postman's request using JMeter's HTTP(S) Test Script Recorder, if you configure Postman to use JMeter as the proxy - JMeter will intercept the request and produce the relevant HTTP Request sampler and HTTP Header Manager. See How to Convert Your Postman API Tests to JMeter for Scaling article for more information.
I am trying to access a document with _id.
I recently dumped an index from remote server to my local server.
Here's how I am trying to get the document:
GET http://localhost:9200/dmap_product_match/dmap_product_match/ZA2JeGsBsz9baORiZSkN
And in response:
{
"_index": "dmap_product_match",
"_type": "dmap_product_match",
"_id": "ZA2JeGsBsz9baORiZSkN",
"found": false
}
But requesting for the document as a query body returns the document:
GET http://localhost:9200/dmap_product_match/_search
{
"_source": ["s_item_name","r_item_name","human_verdict"],
"query": {
"term":{
"_id": "ZA2JeGsBsz9baORiZSkN"
}
}
}
EDIT: elasticsearch v7.0.0.
ElasticSearch is not finding the document you are asking for because the document type is not well defined in the request.
The api to fetch documents has the following format:
GET http://<host>:<port>/<index>/<type>/<docId>
According to the request you post, you are looking for the document with the id ZA2JeGsBsz9baORiZSkN in the index dmap_product_match and type dmap_product_match.
Your request should be something like:
GET http://localhost:9200/dmap_product_match/_doc/ZA2JeGsBsz9baORiZSkN
According to this documentation [ https://cloud.google.com/tasks/docs/creating-http-target-tasks ], one should be able to create tasks with type 'http_request' and 'http_method' set to 'POST', but the behavior is not the expected once the task is always created with method 'GET'.
After having this issue while using the Python Client Library, I've decided to try the API directly and check if it was an issue with the library or with the API itself.
Using the "Try this API" from the product's documentation page [ https://cloud.google.com/tasks/docs/reference/rest/v2beta3/projects.locations.queues.tasks/create ], I've tried to create similar tasks using both http_request and app_engine_http_request types and always setting the http_method to POST.
If I set the request body like this:
{
"task": {
"appEngineHttpRequest": {
"httpMethod": "POST",
"relativeUri": "/test",
"body": "c2hhbGxvdyBub3c="
}
}
}
...the task is created and the method is POST, like expected. But, if I set the request body to:
{
"task": {
"httpRequest": {
"httpMethod": "POST",
"url": "https://httpstat.us/404",
"body": "c2hhbGxvdyBub3c="
}
}
}
...the task is created, but with method GET instead of POST.
Here's what I get at my queue:
I believe this is a bug, and that's why I'm reporting it here with tag google-apis-explorer as recommended at the support page.
Anyway, if anyone could tell me if I'm doing something wrong or if there's any workaround in the meanwhile I would really appreciate.
Thanks!
Thank You for this post, this is a bug in the existing Cloud Tasks UI and we are in the process of fixing this bug.
In the meantime the correct HTTP method of the task can be determined by running the following command:
gcloud beta tasks describe
https://cloud.google.com/sdk/gcloud/reference/beta/tasks/describe
The above command will show the correct HTTP method for the task.
I've been trying to use the batch endpoint of MailChimp API (version 3.0) to subscribe new users to a list, but can't make it work.
Here is the request:
POST /3.0/batches
{
"operations": [
{
"method" : "POST",
"path" : "lists/c852ce5c86/members",
"body": "{\"email_address\":\"email#domain.tld\", \"status\":\"subscribed\"}"
}
]
}
The request seems ok cause I get a 200 response:
{
"id": "49abca6ef3",
"status": "finished",
"total_operations": 1,
"finished_operations": 1,
"errored_operations": 1,
"submitted_at": "2015-09-21T18:11:16+00:00",
"completed_at": "2015-09-21T18:11:23+00:00",
"response_body_url": "https://mailchimp-api-batch.s3.amazonaws.com/49abca6ef3-response.tar.gz?..."
}
However, as you can see, the only operation in my batch is errored.
Here is the response_body_url for this operation:
[{
"status_code":400,
"operation_id":null,
"response":"{
\"type\":\"http://kb.mailchimp.com/api/error-docs/400-invalid-resource\",
\"title\":\"Invalid Resource\",
\"status\":400,
\"detail\":\"The resource submitted could not be validated. For field-specific details, see the 'errors' array.\",
\"instance\":\"\",
\"errors\":[{
\"field\":\"\",
\"message\":\"Schema describes object, NULL found instead\"
}]
}"
}]
which is not very helpful :(
Note that if I directly hit POST lists/c852ce5c86/members with {"email_address":"email#domain.tld", "status":"subscribed"} payload, it's working properly.
That was actually a bug in the mailchimp API. After reaching them they quickly fixed it.