RESTful Basic Authentication using TestProject

Hi All,

So I’m having trouble related to the following article:

In short I’m getting an error related to unauthorized credentials.

I think this may be happening due to the backslash in my username please see example below:

domain\firstname.surname
Password1!

I have read base64 does not support backslash, so I was wondering if there is any other way around this to authenticate the above.

Hello @amrit.bains and welcome to our community!
You can execute this command using the ‘Execute JavaScript’ sending your request
You can see this example code for an HTTP GET request from Stack Overflow (HTTP GET request in JavaScript? - Stack Overflow):

function httpGet(theUrl)
{
    var xmlHttp = new XMLHttpRequest();
    xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
    xmlHttp.send( null );
    return xmlHttp.responseText;
}

You can also send a cURL command using the ‘Execute’ action.

Let me know if this information helped you.

Hi Ran,

Thank you for the quick reply.

I replaced ‘theUrl’ in your script with the API url, using the execute JavaScript addon I got the following message:

javascript error: Unexpected token ‘:’

I was unsure as to where I need to enter my username and password using the above script?

Hi @amrit.bains.
You can head headers by adding xmlhttp.setRequestHeader("headerName","headerValue")
after xmlHttp.open.

You can also use the ‘Execute’ action to send your API request with cURL.
Here is an API example from TestProject:

curl -X GET "https://api.testproject.io/v2/projects/<YourProjectID>/jobs?_start=0&_limit=10" -H "accept: application/json" -H "Authorization: <YourAPIKey>"

You can implement it to your request and put your headers after ‘-H’

You can read here for more information.

If you need more personal assistance please contact our support mail at support@testproject.io