Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get API response using Restinstance with Robot Framework?

I'm a robot framework newbie. I'm trying everything I can possible think of but for some reason I'm still unable to get the correct result. I'm trying to use the combination of Rest and RestInstance library to create session for a website then log API's response.

When I use the following method, I got this error.

15:52:15.075 FAIL ValueError: need more than 1 value to unpack

Get User API Response
${auth}=    Create List    ${example_email}    ${pwd}
Create Session    a    website/api/sign_in    ${headers}    123    ${auth}

When I use this method I cannot successfully create an active session with account log-in thus return incorrect info.

${headers}=    Create Dictionary    csrf_token=123
Create Session    a    website/api/sign_in    ${headers}    123    ${auth}
Rest.Get    website/api/sign_in
Rest.Output    response

I'm not understanding what I did wrong. If anyone could point the right directions with be gratefully appreciated.

like image 908
Joan40727 Avatar asked Apr 14 '26 17:04

Joan40727


1 Answers

You can do the following You are trying to do the correct thing just assign Rest.Ouput to a variable and that way you can log it or verify the response

*** Keywords ***
Sample Rest
  ${Response_Body_Verify} =  set variable  Sample Data
  ${headers}=    Create Dictionary    csrf_token=123
  Create Session    a    website/api/sign_in    ${headers}    123    ${auth}
  Rest.Get    website/api/sign_in
  ${Response} =  Rest.Output    response body
  should be equal  ${Response}  ${Response_Body_Verify}
like image 80
AutoTester213 Avatar answered Apr 17 '26 23:04

AutoTester213



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!