Skip to content Skip to sidebar Skip to footer

How To Add Headers For CreateSession In Robot Framework HTTP Requests Library

I am using the requests library in Robot framework provided at this github link. The documentation implies that if can send custom headers by doing CreateSession head

Solution 1:

You aren't passing a dictionary, you're passing a string that looks like a dictionary. The solution is to create a proper dictionary and pass that in. Robot has a Create Dictionary keyword for this purpose.

*** Settings ***
| Library | Collections

*** Test Cases ***
| Example
| | ${headers}= | Create dictionary
| | ... | header1 | value1
| | ... | header2 | value2
| | CreateSession | SendCustomHeader | http://myhost.com  
| | ... | header=${headers} | verify=False 

Solution 2:

According to the Requests documentation, you may add headers to the Session object as:

s = requests.Session()
s.auth = ('user', 'pass')
s.headers.update({'x-test': 'true'})

Post a Comment for "How To Add Headers For CreateSession In Robot Framework HTTP Requests Library"