question

Neetha avatar image
Neetha asked mabass edited

Rest session profile, POST http request with variables

I want to automate a Rest API - with HTTP POST request. Since the payload may change, I want to give them as variables. (Please refer the IMAGE included with this e-mail.) But I cannot save this configuration, or capture steps as in the case of web session. Can someone suggest to me as to how I may accomplish the same using itest REST session profile such that I may be able to call those steps via a procedure from within test-case. Is there any alternative way of doing this? ![![alt text][1]][1] [1]: /storage/temp/4550-restprofile.png
iTestrest session profilehttp postcapture steps with rest session profile
restprofile.png (15.3 KiB)
restprofile.png (15.3 KiB)
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

mabass avatar image
mabass answered mabass edited
We can achieve that following the below steps: - Set / Create the variables for Header and Value. - Then use that in the testcase as shown in the below screenshot. ![alt text][1] Kindly, try this and let me know if it works. [1]: /storage/temp/4583-rest.jpg

rest.jpg (58.6 KiB)
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Neetha avatar image
Neetha answered
I had a quick question. When we use 'Variables & Parameters' in the testcase, how do we specify that the variables that are HTTP header key and value? Please refer my first image, for those steps in the session window, what would be the correct steps in test-case. Are there any tutorials regarding the same? ![alt text][1] [1]: /storage/temp/4574-step_httppost_header.png

10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Neetha avatar image
Neetha answered Neetha commented
Thankyou so much for the response, I will try it out and let you know!
2 comments
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

mabass avatar image mabass commented ·
Could you please let me know if the above suggestions worked.
0 Likes 0 ·
Neetha avatar image Neetha mabass commented ·
It worked for me for HTTP POST url. I wasn't sure about the HTTP header values and so I asked another question.
0 Likes 0 ·
mabass avatar image
mabass answered mabass edited
We can't use the Variables or Parameters in the session window. However we can use the same Variables & Parameters in the testcase. To achieve this kindly follow the below steps: - Create a Rest Session Profile and give $URL in the session as shown in the below screenshot and make sure that the Field Substitution is enabled. ![alt text][1] - Create a Test Case Manually and add all the required steps. - If you are using Variables, kindly make sure that the same variables are defined before the steps where you are using them. - If you are using Parameters, make sure that the parameters are either defined in testcase Parameters tab or in the Global Parameter file. - Just like in session profile, for all the steps where you are using Variables or Parameters, make sure that the field substitution is enabled as shown in the below screenshot: ![alt text][2] Try the above steps and let me know if it works. [1]: /storage/temp/4552-url.jpg [2]: /storage/temp/4554-rest_variable.jpg

url.jpg (32.8 KiB)
rest_variable.jpg (86.9 KiB)
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.