Get json data and complete a webform

Hello, how are you? I am trying my first robots, in this case I need to obtain information from a JSON that is published in an webapi and then complete a web form in another url.

I am starting with the log in and creation of the dictionaries but I have problems with a variable.

*** settings ***
Library Collections
Library requests
Library Rest
Library RPA.Browser

*** Variables ***
${BASE_URL} http://10.75.160.27:81

{json1}= Set Variable {{result.json()}

*** test cases ***
Caso_Test_1
#{result} = get {hi1}
{result} = get {BASE_URL}

Should Be Equal  ${result.status_code}  ${200}

{json} = Set Variable {result.json()}

${framework} =  Get From Dictionary  ${json1}  framework

Caso_Test_1 | FAIL |
Variable ‘${json1}’ not found.

what is the reason why my variable is not working?

after capture the data of json I need to complete a webform that that I already have in another robot
Thanks!!

Hi Mike

I see some syntax errors in the code sample that you posted. Some of these may be just copy/paste artifacts:

  • All parameters must be separated with 2 (or more) spaces from each other and from keyword
  • Keywords inside test cases must be indented with 2 (or more) spaces.
  • Variables always start with $ sign e.g. ${hi1}

Example:

    ${result}=    Get    ${BASE_URL}

I put here an example of robot that does similar action. Get JSON document and write a value to log. However, it used RPA.HTTP library, which extends requests library with some shortcut keywords such as GET HTTP.

*** Settings ***
Library    RPA.HTTP

*** Variables ***
${BASE_URL}    http://time.jsontest.com

*** Task ***
Get Time
    ${result}=    Http Get    ${BASE_URL}
    Should Be Equal    ${result.status_code}    ${200}
    Log    ${result.json()}[time]
1 Like

The reason for ${json1} not found error is that you should use ${json} instead of ${json1} in line

${framework} =  Get From Dictionary  ${json1}  framework
1 Like