How to use REST Library in Robot Framework?

8,820 views
Skip to first unread message

finspin

unread,
Oct 16, 2012, 5:46:22 AM10/16/12
to robotframe...@googlegroups.com

Does anybody know how to use the REST Library for Robot Framework? The library is available here http://code.google.com/p/robotframework-restlibrary/source/browse/trunk/RestLibrary.py. It seems like there is no documentation available.

I tried something like this in Robot Framework but there is no response coming back from the request:

REST Test Case
    Get         https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810,-119.6822510&timestamp=1331161200&sensor=true
    Response    test
 

Any ideas how to use this library?

Stephen Jefferies

unread,
Oct 17, 2012, 8:20:54 AM10/17/12
to robotframe...@googlegroups.com
Not sure about that particular library - it hasn't been touched for a few years though so you would probably be better off looking at one of the other HTTP libraries out there and see if they do what you need. There are two listed in the test libraries page of the RF site:

I personally use the first of these since it allows you to write slightly more verbose tests but thats personal preference. Both have documentation and examples of usage if you take a look at the tests folder in the source of either. 

Bulkan

unread,
Oct 17, 2012, 7:00:37 PM10/17/12
to stevej...@gmail.com, robotframe...@googlegroups.com
Hi all,

Im the creator of robotframework-requests if you need more features please ask me and I shall add them.

Cheers


--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/robotframework-users/-/N0NPFsjqo6wJ.

To post to this group, send email to robotframe...@googlegroups.com.
To unsubscribe from this group, send email to robotframework-u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/robotframework-users?hl=en.

Ragavan Varatharajan

unread,
Jun 13, 2014, 6:19:41 AM6/13/14
to robotframe...@googlegroups.com, stevej...@gmail.com
Hi,

Is it possible to have "Patch" in the http request library ?

Thanks for you reply.
Cheers


To unsubscribe from this group, send email to robotframework-users+unsub...@googlegroups.com.

Laurent Bristiel

unread,
Jun 16, 2014, 3:19:10 AM6/16/14
to robotframe...@googlegroups.com, stevej...@gmail.com
yes, patch is available.

Ragavan Varatharajan

unread,
Jun 16, 2014, 5:35:57 AM6/16/14
to robotframe...@googlegroups.com, stevej...@gmail.com
Thanks !

test....@gmail.com

unread,
Jul 9, 2014, 7:15:34 PM7/9/14
to robotframe...@googlegroups.com, stevej...@gmail.com
Hi,

Is robotframework-requests library supporting the REST API ?

If REST API returns JSON or XML , can this library handle both ?

I am completely new to robot framework and am looking for REST API libraries, which can handle JSON and XML both.

Thanks.
Cheers


To unsubscribe from this group, send email to robotframework-users+unsub...@googlegroups.com.

Laurent Bristiel

unread,
Jul 10, 2014, 3:29:44 AM7/10/14
to robotframe...@googlegroups.com, stevej...@gmail.com
yes and yes, you can try it out. Should work fine.
Laurent

Andrei Paraschiv

unread,
Nov 29, 2014, 9:31:38 AM11/29/14
to robotframe...@googlegroups.com
Hi,

I am having some trouble with the library.
Could you please help me?

Thank you.
-------------

This works fine

Post Requests
    [Tags]  post
    Create Session  httpbin  http://httpbin.org
    ${data}=  Create Dictionary  name  bulkan  surname  evcimen
    ${headers}=  Create Dictionary  Content-Type  application/x-www-form-urlencoded
    ${resp}=  Post  httpbin  /post  data=${data}  headers=${headers}
    Dictionary Should Contain Value  ${resp.json()['form']}  bulkan
    Dictionary Should Contain Value  ${resp.json()['form']}  evcimen


This too,

Get Requests
    [Tags]  get
    Create Session  swagger  http://petstore.swagger.wordnik.com:80/api/pet/400
    ${resp}=  Get  swagger  /
    Should Be Equal As Strings  ${resp.status_code}  200
    ${jsondata}=  To Json  ${resp.content}
    Log  ${jsondata}

   
However this does not.

Post Requestss
    [Tags]  post
    Create Session  swagger  http://petstore.swagger.wordnik.com:80/api
    ${data}=  Create Dictionary  id  88  name  gerbil  status  available
    ${headers}=  Create Dictionary  'content-type'  'application/json'
    ${resp}=  Post  swagger  /pet  data=${data}  headers=${headers}
    Dictionary Should Contain Value  ${resp.json()['id']}  88
    Dictionary Should Contain Value  ${resp.json()['name']}  gerbil

It gets:

KEYWORD: ${resp} = RequestsKeywords.Post swagger, /pet, data=${data}, headers=${headers}
Documentation:

Send a POST request on the session object found using the

Start / End / Elapsed: 20141129 16:25:05.031 / 20141129 16:25:05.605 / 00:00:00.574
16:25:05.033 INFO Starting new HTTP connection (1): petstore.swagger.wordnik.com
16:25:05.605 INFO ${resp} = <Response [415]>
00:00:00.001 KEYWORD: Collections.Dictionary Should Contain Value ${resp.json()['id']}, 88
Documentation:

Fails if `value` is not found from `dictionary`.

Start / End / Elapsed: 20141129 16:25:05.605 / 20141129 16:25:05.606 / 00:00:00.001
16:25:05.606 FAIL Resolving variable '${resp.json()['id']}' failed: KeyError: 'id'

Andrei Paraschiv

unread,
Nov 29, 2014, 12:54:21 PM11/29/14
to robotframe...@googlegroups.com
Fixed it.
It took only a tcp dump to figure out that I had some extra quotes that were not needed.in the headers definition.

*** test cases ***
Get Requests
    [Tags]  get

    ${headers}=  Create Dictionary  content-type  application/json
    Create Session  swagger  http://petstore.swagger.wordnik.com:80/api/pet/400    headers=${headers}

   
    ${resp}=  Get  swagger  /
    Should Be Equal As Strings  ${resp.status_code}  200
    ${jsondata}=  To Json  ${resp.content}
    Log  ${jsondata}
   
Post Requests
    [Tags]  post

    ${headers}=  Create Dictionary  content-type  application/json
    Create Session  swagger  http://petstore.swagger.wordnik.com:80/api  headers=${headers}


    ${data}=  Create Dictionary  id  88  name  gerbil  status  available
    ${resp}=  Post  swagger  /pet  data=${data}
   
    Log  ${resp.text}
    Should Not Contain  ${resp.text}  415

Put Requests
    [Tags]  put

    ${headers}=  Create Dictionary  content-type  application/json
    Create Session  swagger  http://petstore.swagger.wordnik.com:80/api  headers=${headers}

    ${data}=  Create Dictionary  id  77  name  cow  status  sold
    ${resp}=  Put  swagger  /pet  data=${data}

    Log  ${resp.text}
    Should Not Contain  ${resp.text}  415


Santosh Karki

unread,
Jul 11, 2017, 7:31:25 PM7/11/17
to robotframework-users, stevej...@gmail.com
Hi Steve,

I am new to using robot framework and I am to work in testing RESTful services. In the previous regard, can you please illustrate an example of a test case how both XML and JSON responses can be returned?


Thanks
Santosh
Reply all
Reply to author
Forward
0 new messages