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

**URL:** <https://forum.robotframework.org/t/mark-test-status-after-test-has-completed-using-rest-api-in-browserstack-using-robotframework/6024>\
**Category:** Robot Framework\
**Created:** [27 July 2023 19:55 UTC](https://forum.robotframework.org/t/mark-test-status-after-test-has-completed-using-rest-api-in-browserstack-using-robotframework/6024 "2023-07-27T19:55:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rachel](https://avatars.discourse-cdn.com/v4/letter/r/46a35a/32.png) [@Rachel](https://forum.robotframework.org/u/Rachel)\
**Post date:** [27 July 2023 19:55 UTC](https://forum.robotframework.org/t/mark-test-status-after-test-has-completed-using-rest-api-in-browserstack-using-robotframework/6024/1 "2023-07-27T19:55:23Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [27 July 2023 23:40 UTC](https://forum.robotframework.org/t/mark-test-status-after-test-has-completed-using-rest-api-in-browserstack-using-robotframework/6024/2 "2023-07-27T23:40:13Z")

</div>

Hi Rachel,

It looks like you might be using Requests Library?

If I’m right, you probably want to use [PUT On Session](https://marketsquare.github.io/robotframework-requests/doc/RequestsLibrary.html#PUT%20On%20Session) rather than [PUT](https://marketsquare.github.io/robotframework-requests/doc/RequestsLibrary.html#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.
