behinddwalls
behinddwalls

Reputation: 618

JSON Post data request in JMeter

I have a rest web-service which accepts JSON post data but for requesting any API url, we need to pass access_token.
So my post data is a JSON data and access_token is passed as query string.

Below is the expected request data.

How should i configure it in JMeter?

Upvotes: 1

Views: 8385

Answers (2)

UBIK LOAD PACK
UBIK LOAD PACK

Reputation: 34566

In path field, add access_token like this:

  • path?access_token=${value extracted by regexp}

And use raw post body for the JSON content.

Upvotes: 1

behinddwalls
behinddwalls

Reputation: 618

I just found the solution for this .

Instead of using Header Manager , I have used BeanShell preprocessor where I just removed the argument from the aeguments availble in Beanshell preprocessor and addded the QueryString to path of the request using setPath() method available in BeanShell Preprocessor .

Arguments arguments = sampler.getArguments();
String access_token = sampler.getArguments().getArgumentsAsMap().get("access_token");
arguments.removeArgument("access_token");
String path = sampler.getUrl() + "?access_token=" + access_token;
sampler.setPath(path);

This code solved my problem. Alternate is HeaderManager. Already Answered by @PMD UBIK-INGENIERIE

Upvotes: 0

Related Questions