Mark test status after test has completed using REST API in Browserstack using RobotFramework

Hello,

I am trying to use the Robot Framework’s with Borwserstack and I am facing a difficulty. I’m using the REST API that the documentation goes through:
curl -u “username:accesskey”
-X PUT “https://api-cloud.browserstack.com/app-automate/sessions/session_id.json
-H “Content-Type: application/json”
-d ‘{“status”:“failed”, “reason”:“Element not found on the login page”}’

But I get the following error “HTTPError: 401 Client Error: Unauthorized for url” This is the code in robot framework:
Set Status Session
${auth} = Set Variable ${BS_USERNAME}:${BS_ACCESSKEY}
${url} = Set Variable ${BS_MARK_TEST_STATUS}
${headers} Create Dictionary auth=Basic ${auth}
Create Session browserstack ${url} ${headers}
${response} = PUT browserstack /
Log ${response.json()}
Log Response Status Code: ${response.status_code}

Does anyone know how to resolve? Thanks.

Hi Rachel,

It looks like you might be using Requests Library?

If I’m right, you probably want to use PUT On Session rather than PUT which ignores the session you created with Create Session

There was a change to the Requests Library keywords around version 0.8 that changed their behaviour so if you are following an old example it might give you the old format.

Hope that helps,

Dave.

1 Like