0
votes

I recorded my project website workflow on Jmeter. But On rerunning the recorded samples, all the samples having POST request are failing. I am unable to figure out why the same samples which were passing during recording, are failing on re-run.

Below is request of one of the samples which is failing:

Recorded sample request which passed:


    POST https://example.com/live/v1/dashboards/promo_pa/ds/promo_program_dimensions

    POST data:
    {"query":"promo_program_dimensions.filterby(program_master_id = 'GOGGLE').filterby(dimension_name = 'channel').groupby(dimension_value).aggregate(count(dimension_value) as count).orderby(dimension_value+)"}

    [no cookies]

    Request Headers:
    Connection: keep-alive
    Referer: https://example.com/live/v1/dashboards/promo_pa/
    Accept-Language: en-US,en;q=0.5
    DNT: 1
    Accept: */*
    X-Requested-With: XMLHttpRequest
    Content-Type: application/json
    Accept-Encoding: gzip, deflate, br
    User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0
    Content-Length: 216
    Host: example.com

Sampler Result:


    Thread Name: 
    Sample Start: 2018-02-22 17:32:44 IST
    Load time: 93
    Connect Time: 58
    Latency: 93
    Size in bytes: 647
    Sent bytes:1095
    Headers size in bytes: 645
    Body size in bytes: 2
    Sample Count: 1
    Error Count: 0
    Data type ("text"|"bin"|""): text
    Response code: 200
    Response message: OK

    Response headers:
    HTTP/1.1 200 OK
    Server: nginx
    Date: Thu, 22 Feb 2018 12:02:44 GMT
    Content-Type: text/html; charset=utf-8
    Content-Length: 2
    Connection: keep-alive
    Cache-Control: no-cache, no-store, must-revalidate, public, max-age=0
    Set-Cookie: live=.eJxNj11vgjAYhf_K0muzMLJdSOIFC6yBQJmuiO1Nw0cdtB0zUEAw_nfRZcbLN2_Oc85zAoGNHA9B9mlDF1gn8JQBCwTm8VD8xH0h3J7CjymFfk92vszHZZklxzpdr1bgvABBBKHrMA-x-MvdzEFVZbzRI1gAtm94WwJLNx2fr6q4wymWr9RRiuJ8iJJtRRLyQsytouJdULwREUQKJfGAkvBWkrfNnulfyes7IhTxQCGqiLkeIqeQaAqn0EElxa5B8feEoK-IkFesDLFnUMd-C4e_zVXBa13p8TntdMn0eODAqjulHj4PY8lua6RwOV6TXcubm8is2XP273q-AI7Dam4.DXBC5A.CJMLbN0B4HC4U8703ZQS50K00lk; HttpOnly; Path=/live

    HTTPSampleResult fields:
    ContentType: text/html; charset=utf-8
    DataEncoding: utf-8

Request of the same sample which is failing on re-run:


    POST https://example.com/live/v1/dashboards/promo_pa/ds/promo_program_dimensions

    POST data:
    {"query":"promo_program_dimensions.filterby(program_master_id = 'GOGGLE').filterby(dimension_name = 'channel').groupby(dimension_value).aggregate(count(dimension_value) as count).orderby(dimension_value+)"}

    Cookie Data:
    live=.eJxNj11vgjAYhf_K0muzuE4uJPHCBNZgaB0O1Pam4aOu5WsGCqMY__uYy4yXJ2_O857nAvw1cTyC-PsaucC-gKcE2MCHwzmroj7L3Z6htzFGm54eN0VqljI5DHUcrFbgOgP-FiHX4R7h0Ye7m4qlSkSjDZgBfmpEK4Gtm05MSWV3OK5YgR3XohXJcR4tyCgVzvdTSi0WUoshOt86HiRhcHuSts2J669C1HcEgdhgJ10wx3shI4a02uUYRiMNpSIwGFguCxyuzYR6ZaEs8SH4xp9_m1Umaq20eY47Lbk2ZwHsuivLh8vDWHrcz2O0NL_NrhXNTWTS7AX_d73-AAjCaeE.DXBNjA.Fy0Fs7zpVKg-f1qSbAljATOn64E

    Request Headers:
    Connection: keep-alive
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 216
    Host: example.com
    User-Agent: Apache-HttpClient/4.5.3 (Java/1.8.0_161)

Sampler Result:


    Thread Name: Liberty 1-1
    Sample Start: 2018-02-22 18:24:46 IST
    Load time: 26
    Connect Time: 0
    Latency: 26
    Size in bytes: 709
    Sent bytes:868
    Headers size in bytes: 652
    Body size in bytes: 57
    Sample Count: 1
    Error Count: 1
    Data type ("text"|"bin"|""): text
    Response code: 400
    Response message: BAD REQUEST

    Response headers:
    HTTP/1.1 400 BAD REQUEST
    Server: nginx
    Date: Thu, 22 Feb 2018 12:54:46 GMT
    Content-Type: text/html; charset=utf-8
    Content-Length: 57
    Connection: keep-alive
    Cache-Control: no-cache, no-store, must-revalidate, public, max-age=0
    Set-Cookie: live=.eJxNj1tvgjAAhf_K0mezGAcPkvjg0q7B0DKciO1Lw6WGcpuBwizG_z50mfHx5ORcvgvw1hS6FIvPNUbAuYCXBDjAW5xPWR0OWYEGjj_GGG8GdtiUqVnmSXRu4mC1AtcZ8HyMERQuFeEX2k7BSiWy1QbMgDi2ssuBo9teTkplj3JS85JAZLOaFqQILTrmihT7SaU23zGbYzb3obugu-A-knbtUejvUjaPCh9Wio7vFY22ikBm0SKrCeSlDwOL79I3OpajjwOLRTRnUWh4jSz28_dZZbLRSpvXuNe50OYkgdP0VfXkPJ1lh_08xktzS_adbO8gE-YgxT_r9Rcq0WoP.DXBPFg.4Rll1tgU0GdWHWyE73uLkKM8z9c; HttpOnly; Path=/live


    HTTPSampleResult fields:
    ContentType: text/html; charset=utf-8
    DataEncoding: utf-8

Response Data:


    {"error": "Failed to authenticate user for data access."}

I have a login sample before this which passed successfully, So user has logged-in successfully before this sample.

I have used HTTP Cache Manager, HTTP Cookie Manager and HTTP Header Manager. HTTP Cookie Manager will manage the session automatically. Still i am getting authentication error.

i have used the default settings for the sample i.e. "Redirect Automatically" and "Use KeepAlive". I am using JMeter 3.3

Appreciate any pointers.

1
Second request that failed is with cookie, without cookie manager it works?user7294900
Answer provided by "Dmitri T" worked.Huzefa

1 Answers

0
votes

In the "successful" request you have the following HTTP Headers:

X-Requested-With: XMLHttpRequest
Content-Type: application/json

In the "failing" one you have:

Content-Type: application/x-www-form-urlencoded

So my expectation is that you need to add HTTP Header Manager as a child of the "failing" request and configure it to send Content-Type header with the value of application/json