I'm learning API autotesting and writing tests on Eclipse(Java). Before I had trial on localhost and the following code was working to authenticate:
String response = given().header("Content-Type", "application/json").body("{ \"username\": \"blablabla@gmail.com\", \"password\": \"vfnvdf\" }" ).log().all().filter(session).post("/rest/auth/1/session").then().log().all().
extract().response(). asString();
But now, it has expired and I've moved to "https://testing-api.atlassian.net" and I cannot understand what to modify.
I found that example code "curl -D- \ -X GET \ -H "Authorization: Basic ZnJlZDpmcmVk" \ -H "Content-Type: application/json" \ "https://your-domain.atlassian.net/rest/api/2/issue/QA-31"" and I generated my token on Jira, but I cannot understand how to put it into my code
please help
If I run it, it tells me:
"
HTTP/1.1 401 Unauthorized
Server: AtlassianProxy/1.15.8.1
www-authenticate: JIRA REST POST
www-authenticate: OAuth realm="https%3A%2F%2Ftesting-api.atlassian.net"
cache-control: no-cache, no-store, no-transform
Content-Type: application/json;charset=UTF-8
Strict-Transport-Security: max-age=315360000; includeSubDomains; preload
Date: Fri, 26 Feb 2021 07:30:35 GMT
ATL-TraceId: 6d9b29cebff5e3d5
x-arequestid: 6b8c29dd-62d0-4d1d-ab00-f068e083f4bd
X-XSS-Protection: 1; mode=block
Transfer-Encoding: chunked
timing-allow-origin: *
x-envoy-upstream-service-time: 19
X-Content-Type-Options: nosniff
Connection: keep-alive
set-cookie: atlassian.xsrf.token=b8f587a6-a6a8-4887-99fe-198ec696f65e_170d7685aacb6b99e56f047eec1d73e42a90d3f2_lout; Path=/; Secure
set-cookie: jsd.portal.language.anonymous=en-US; Expires=Fri, 26-Feb-2021 07:31:35 GMT; Path=/
Expect-CT: report-uri="https://web-security-reports.services.atlassian.com/expect-ct-report/global-proxy", enforce, max-age=86400
{
"errorMessages": [
"Login failed"
],
"errors": {
}
}"