0

Precondition: Need To Login Application first, then I can send my API request to the server, so who can set this thing in Jmeter?

Current: I am getting error as

"{"Message":"Request was not made within the context of a valid session.","Data":"ErrorId: "}"

2 Answers 2

0

Try adding HTTP Cookie Manager to your Test Plan, if the "session" is being handled by cookies - the Cookie Manager will automatically resolve it.

If not - then most probably you will need to perform correlation - the process of detecting dynamic element(s), extracting them into JMeter Variable(s) using a suitable JMeter PostProcessor and replacing recorded hard-coded value in the next request with the JMeter Variable.

Example test plan outline:

  • Request 1
    • Post Processor to extract token from the Request 1 into variable token
  • Request 2 sending ${token} from the request 1 as a parameter

You can consider an alternative way of recording a JMeter test using cloud-based proxy service, it is capable of exporting recorded scripts in "SmartJMX" format which automatically detects and handles dynamic parameters. See How to Cut Your JMeter Scripting Time by 80% article for more details.

0

To do Basic Auth, just add HTTP Authorization Manager to your plan as per this answer:

It would be configured like this if your server URL is http://localhost:8080/test:

Http Authorization Manager

There is no need for scripting here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.