ALM QC 16.0.1 API connection returns '?login-form-required=y' 401 error

Hello!

I am trying to create a class for an Automation framework that will manage the ALMQC connection for updating runs, creating defects, and so on. I am following the official API documentation regarding this, but I am encountering a blocker and don't really know how to continue.

1) So first I log using apikey and secret:


Request method:	POST
Request URI:	https://baseURL/qcbin/rest/oauth2/login
Proxy:			<none>
Request params:	<none>
Query params:	<none>
Form params:	<none>
Path params:	<none>
Headers:		Accept=*/*
				Content-Type=application/json
Cookies:		<none>
Multiparts:		<none>
Body:
{
    "clientId": "apikey",
    "secret": "secret"
}
Authentication successful! Session Token: {lwssoSessionCookie}

From here I take LWSSO_COOKIE_KEY value

2) Then I perform a QC Session:

Request method:	POST
Request URI:	https://baseURL/qcbin/rest/site-session
Proxy:			<none>
Request params:	<none>
Query params:	<none>
Form params:	<none>
Path params:	<none>
Headers:		Cookie=LWSSO_COOKIE_KEY={lwssoSessionCookie}
				Accept=*/*
				Content-Type=application/x-www-form-urlencoded; charset=ISO-8859-1
Cookies:		<none>
Multiparts:		<none>
Body:			<none>
QC Session created successfully

From here I take the XSRF-TOKEN value

3) Now I am supposed to be able to send a create request post and be able to create it on my project:

Request method:	POST
Request URI:	https://baseURL/qcbin/rest/domains/DOMAIN/projects/PROJECT/defects
Proxy:			<none>
Request params:	<none>
Query params:	<none>
Form params:	<none>
Path params:	<none>
Headers:		Cookie=LWSSO_COOKIE_KEY={cookievalue}
				X-XSRF-TOKEN={tokenvalue}
				Accept=application/json
				Content-Type=application/json
Cookies:		<none>
Multiparts:		<none>
Body:
{
    "Fields": [
        {
            "Name": "detected-by",
            "values": [
                {
                    "value": "sa"
                }
            ]
        },
        {
            "Name": "creation-time",
            "values": [
                {
                    "value": "2010-03-02"
                }
            ]
        },
        {
            "Name": "severity",
            "values": [
                {
                    "value": "2-Medium"
                }
            ]
        },
        {
            "Name": "name",
            "values": [
                {
                    "value": "Returned value does not match value in database."
                }
            ]
        }
    ]
}
Failed to create defect. Response: {"Id":"qccore.general-error","Title":"Authentication failed. Browser based integrations - to login append '?login-form-required=y' to the url you tried to access.","ExceptionProperties":null,"StackTrace":null}
java.lang.RuntimeException: Failed to create defect! Status code: 401

So I am getting a 401 error with the login append '?login-form-required=y' thing that i don't understand why, could someone help me here?

Thanks in advance!