1

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.

  • Problem:

    As per my exploration i have not found any way to send request which can have JSON post data and also accepts Query String from the HTTP-URL-REWRITING in JMeter.

  • Actual Request:

    POST http://<domain>/webapp/service/document/save    
    POST data: { node = '1'}token_XXXXXX
    [no cookies]    
    Request Headers: Connection: keep-alive Content-Type: application/x-www-form-urlencoded Content-Length: 980 Host: localhost User-Agent: Apache-HttpClient/4.2.3 (java 1.5)
    

Below is the expected request data.

  • Expected Request:

    POST http://<domain>/webapp/service/document/save?access_token=token_XXXXXX    
    POST data: { node = '1'}   
    [no cookies]  
    Request Headers: Connection: keep-alive Content-Type: application/x-www-form-urlencoded Content-Length: 980 Host: localhost User-Agent: Apache-HttpClient/4.2.3 (java 1.5)
    

How should i configure it in JMeter?

UBIK LOAD PACK
  • 33,980
  • 5
  • 71
  • 116
behinddwalls
  • 644
  • 14
  • 39

2 Answers2

1

In path field, add access_token like this:

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

And use raw post body for the JSON content.

UBIK LOAD PACK
  • 33,980
  • 5
  • 71
  • 116
0

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

behinddwalls
  • 644
  • 14
  • 39
  • yes.. but if i have just modified the post-data content using HeaderManger then... still i need to append my access_token to url.. thats y i preffered removing argument & appending querystring to url – behinddwalls Jul 26 '13 at 06:12
  • It seems I had misunderstood your question, I updated my andwer – UBIK LOAD PACK Jul 26 '13 at 06:17