How to test REST API that requires session_id
Question ID: 105020
2
0

I have to test a REST API with JSON content. This API requires that the client login first and get a session id. I tried doing this with web_custom_request…but to no avail. This is the sample web_custom_request:

web_custom_request("RestAPI",

"URL=https://{severname}/rest/blablabla",

"Method=POST",

"TargetFrame=",

"Resource=0",

"Referer=",

"Mode=HTTP",

"RecContentType=application/json",

"EncType=application/json",

"Body={REQUEST_JSON_PARAM}",

LAST);

Questions are:

1) If I were to add code to the LoadRunner script and able to extract the session id, how do I pass it to the web_custom_request? Do I use web_add_cookie? Or do I use web_add_header? If so (whether web_add_cookie or web_add_header or any other), what’s the syntax?

2) Or am I doing this all wrong. What other ways can I test this REST API (with JSON)?

I’m using LR 9.5

Marked as spam
Posted by (Questions: 1, Answers: 0)
Asked on May 22, 2013 2:35 pm
430 views
Answers (1)
1
Private answer

Not knowing all the details, I suggest that you record a log in transaction then correlate the SessionId into a parameter. Use the new session Id in your the customer request call or add a cookie depending on the Rest application requirements. You will have to ask the developer where they get the session id from on post log in transactions. Do they get it from a cookie, a header, or in a hidden value pair in subsequent web transactions

Marked as spam
Posted by (Questions: 4, Answers: 41)
Answered on July 18, 2013 6:23 pm
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top