Forum Discussion

jaredcscott's avatar
jaredcscott
New Contributor
3 years ago
Solved

Problems with RESTAPI GET request

I am wanting to GET a test case through the Zephyr Scale RESTAPI within Jira. The project I am wanting to access is called 'CI' and the test case I am interested in is 'I2-T2'. Is there anyone who can help me identify what I am doing wrong? 

 

Below is my request to the RESTAPI for Zephyr scale:

curl -X GET -H "Authorization: Bearer:<Zephyr Scale API Token>" -i "https://campbellscientific.atlassian.net/projects/CI/rest/atm/1.0/testcase/I2-T2"

Here is the response I am receiving:

HTTP/1.1 302 Found
Server: AtlassianProxy/1.19.3.1
vary: Accept-Encoding
Content-Type: text/html;charset=UTF-8
Strict-Transport-Security: max-age=315360000; includeSubDomains; preload
Date: Tue, 29 Jun 2021 18:22:38 GMT
ATL-TraceId: 2e8c2b89dbfbcb35
x-arequestid: 55035ab9-173e-4420-b000-2d599b26c189
location: /login.jsp?os_destination=%2Fprojects%2FCI%2Frest%2Fatm%2F1.0%2Ftestcase%2FI2-T2&permission-violation=true
X-XSS-Protection: 1; mode=block
timing-allow-origin: *
x-envoy-upstream-service-time: 63
X-Content-Type-Options: nosniff
Connection: keep-alive
set-cookie: atlassian.xsrf.token=b24f8288-2294-4bb0-8c68-7ae969b4091d_6d7e09b2243a5c0d9bbd878b73072cfc92561c59_lout; Path=/; Secure
Expect-CT: report-uri="https://web-security-reports.services.atlassian.com/expect-ct-report/global-proxy", enforce, max-age=86400
Content-Length: 0

 

If I alter my request to point to the URL given (/login.jsp?os_destination=%2Fprojects%2FCI%2Frest%2Fatm%2F1.0%2Ftestcase%2FI2-T2&permission-violation=true) then I will receive a 200 ok response but the data is a login page in a state of error like so:

 

HTTP/1.1 200 OK
Date: Tue, 29 Jun 2021 18:25:21 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 9823
Server: globaledge-envoy
X-Ratelimit-Limit: 1600
X-Ratelimit-Remaining: 1599
X-Ratelimit-Reset: 1624991181
Cache-Control: private, no-cache, max-age=0, no-store, must-revalidate
Pragma: no-cache
X-Frame-Options: SAMEORIGIN
Set-Cookie: atlassian.account.ffs.id=82afe2a2-2404-4c42-bd2d-2b32ed2c2125; Expires=Wed, 29 Jun 2022 18:25:21 GMT; HttpOnly
Set-Cookie: atlassian.account.xsrf.token=1eea8f42be0c554c2f33ddf68127c559a8f2605f; Path=/; Secure; HttpOnly
Set-Cookie: atlassian.account.code.verifier=A-pIE6xg2pLWL_jRqjDxQ0Bw5QIwXQi1Mtc3haOdK2w; Expires=Tue, 29 Jun 2021 19:25:21 GMT; Path=/; HttpOnly
Set-Cookie: cloud.session.token=deleted; Expires=Wed, 01 Jan 1800 00:00:00 GMT; Path=/; Secure; HttpOnly
Set-Cookie: cloud.session.token=deleted; Expires=Wed, 01 Jan 1800 00:00:00 GMT; Domain=id.atlassian.com; Path=/; Secure; HttpOnly
X-Envoy-Upstream-Service-Time: 16
Referrer-Policy: origin
Expect-Ct: report-uri="https://web-security-reports.services.atlassian.com/expect-ct-report/idproxy", max-age=86400
X-Logging-Id: SkaBM08G
Strict-Transport-Security: max-age=63072000; preload
X-Content-Type-Options: nosniff
X-Xss-Protection: 1; mode=block
Atl-Traceid: c7ecf0a44d25a665

<!doctype html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="description" content="Log in to Jira, Confluence, and all other Atlassian Cloud products here. Not an Atlassian user? Sign up for free."><meta name="google-site-verification" content="HNNnCkeVQ-w56fqPpX2TTEMRmta5QJ-bDunwoaUep-o"><meta name="" content=""><meta name="" content=""><link rel="shortcut icon" href="https://cpfs-cdn.atlassian.com/assets/shared/id-summit/id-summit-aa-favicon.ico"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link rel="preconnect" href="https://t.castle.io"><link rel="preconnect" href="https://api.segment.io" crossorigin><link rel="preconnect" href="https://accounts.google.com"><link rel="preconnect" href="https://sentry.io" crossorigin><title>Log in with Atlassian account</title><style>.grecaptcha-badge{visibility:hidden}.scriptLoadError{display:flex;align-content:center;background-color:#0747a6;position:absolute;top:0;left:0;width:100%;height:100%;font-size:14px;font-style:normal;font-weight:400;line-height:1.42857142857143;letter-spacing:-.005em;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Fira Sans,Droid Sans,Helvetica Neue,sans-serif}.scriptLoadError .container{color:#fff;margin:0 auto;align-items:center;display:flex;flex-direction:column}.scriptLoadError .content{background:#fff;border-radius:3px;box-shadow:0 10px 10px rgba(0,0,0,.1);box-sizing:border-box;color:#172b4d;padding:48px;width:400px}.scriptLoadError .content{margin-top:48px}.scriptLoadError .content p:first-child{margin-top:0}.scriptLoadError .content a{text-decoration:none;color:#0052cc}.scriptLoadError .logo{margin-top:48px;margin-bottom:0;font-size:40px;line-height:48px}.scriptLoadError .heading{color:#deebff;font-size:24px;font-weight:500;line-height:28px;margin-top:48px}</style><script src="https://metal.prod.atl-paas.net/1.24.0/metal-head.min.js"></script><link href="https://aid-frontend.prod.atl-paas.net/atlassian-id/front-end/5.0.240/static/css/39.c8940395.chunk.css" rel="stylesheet"></head><body data-app-state="{&quot;appConfig&quot;:{&quot;contextPath&quot;:&quot;&quot;,&quot;recaptchaEnterpriseInvisibleKeySite&quot;:&quot;6LcTpeAZAAAAACEXJuZmTp5YVTOUVXnN3TYR_fLM&quot;,&quot;auth0Config&quot;:{&quot;clientId&quot;:&quot;tDP5by46cc3gEck7d2vbHZsqsfrDK6t9&quot;,&quot;tenant&quot;:&quot;atlassian-account-prod&quot;,&quot;domain&quot;:&quot;auth.atlassian.com&quot;,&quot;tokenIssuer&quot;:&quot;https://atlassian-account-prod.pus2.auth0.com&quot;,&quot;callbackUrl&quot;:&quot;https://id.atlassian.com/login/callback&quot;},&quot;recaptchaEnterpriseCheckboxKeySite&quot;:&quot;6LfnteAZAAAAAH3vsGy_TA6P6wBH6jtbMqAeVI8k&quot;,&quot;recaptchaKeySite&quot;:&quot;6LewHQcTAAAAAJgaYVKlQOahz4gnQME8wqUA0z0J&quot;,&quot;segmentIoKey&quot;:&quot;cb2egpwag7&quot;,&quot;recaptchaInvisibleKeySite&quot;:&quot;6LcqAHAUAAAAAKcO583Ymvnq-uRBDPq4njcoW-jK&quot;,&quot;castleAppId&quot;:&quot;337683121243755&quot;,&quot;bitbucketSignupUrlOverrideEnabled&quot;:false,&quot;sentryUrl&quot;:&quot;https://71e54c28be0d49f0bcd732ab30f35faa@sentry.io/275199&quot;,&quot;recaptchaEnable&quot;:true,&quot;bitbucketSignupUrl&quot;:&quot;https://bitbucket.org/account/signup&quot;,&quot;marketingConsentApiUrl&quot;:&quot;https://preferences.atlassian.com/rest&quot;,&quot;googleAuthClientId&quot;:&quot;596149463257-9oquqfivs9on8t8erq23c8qso6vk3cp1.apps.googleusercontent.com&quot;},&quot;featureFlags&quot;:{&quot;aid_signup.microsoft.auth.enabled&quot;:true,&quot;aid_signup.authenticate.via.id.authentication&quot;:true,&quot;aid_signup.disallow.bitbucket.username.login&quot;:true,&quot;aid_signup.apple.auth.enabled&quot;:true,&quot;aid_signup.block.csrf.mismatches.login.authorize&quot;:true,&quot;sign-in-with-slack.enabled&quot;:true,&quot;manage-account.email.change-email-refresh.enabled&quot;:false,&quot;aid_signup.experiment.user_segmentation&quot;:&quot;variation&quot;,&quot;aid_signup.state.redirect.logout.distribution.enabled&quot;:true,&quot;aid_signup.passwordless.signup&quot;:true,&quot;aid_signup.disallow.passwordless.login.for.google.users&quot;:true,&quot;aid_signup.apple.show.hidden.email.warning.enabled&quot;:true,&quot;aid_signup.google.auth.call.get.user.info&quot;:true,&quot;aid_signup.sev.enabled&quot;:true,&quot;aid_signup.domain.claim.data.login.analytics&quot;:true,&quot;aid_signup.recaptcha.threshold&quot;:true,&quot;aid_signup.bans.validate.authentication&quot;:true,&quot;aid_signup.passwordless.signup.mobile.new.flow&quot;:false},&quot;hashedCsrfToken&quot;:&quot;b37489bdb68031f1b6ee3deea56354b4b85eae6a02c700e536b41174089d41b2&quot;,&quot;locale&quot;:&quot;en-US&quot;,&quot;csrfToken&quot;:&quot;1eea8f42be0c554c2f33ddf68127c559a8f2605f&quot;,&quot;microbranding&quot;:{&quot;application&quot;:&quot;jira&quot;,&quot;applicationNameShort&quot;:&quot;jira.atlassian.com&quot;,&quot;applicationLogoClass&quot;:&quot;jira&quot;,&quot;isEmbedded&quot;:&quot;false&quot;,&quot;applicationName&quot;:&quot;Atlassian Bug Reporting &amp; Feature Requests&quot;,&quot;applicationBaseURI&quot;:&quot;http://idm-web-staging.private.atlassian.com:8080/jira/&quot;},&quot;tenantCloudId&quot;:&quot;e7d85e29-46ce-48cc-8ba2-0b5bff108a88&quot;}"><div id="root"><noscript><div class="scriptLoadError"><div class="container"><h1 class="logo">Atlassian</h1><div class="heading">JavaScript is disabled</div><div class="content"><p>You should enable JavaScript to work with this page.</p></div></div></div></noscript><div id="javaScriptLoadError" style="display:none"><div class="scriptLoadError"><div class="container"><h1 class="logo">Atlassian</h1><div class="heading">JavaScript load error</div><div class="content"><p>We tried to load scripts but something went wrong.</p><p>Please make sure that your network settings allow you to download scripts from the following domain:</p><p><b>https://aid-frontend.prod.atl-paas.net/atlassian-id/front-end/5.0.240</b></p></div></div></div></div></div><script>var mfaServerUrl="",ticket="",requestToken="",postActionURL="",userData={userId:"",email:"",friendlyUserId:"",tenant:"",tenantFriendlyName:""},globalTrackingId="";window.onload=function(){document.getElementById("javaScriptLoadError")&&(document.getElementById("javaScriptLoadError").style.display="block")}</script><script>!function(e){function t(t){for(var n,c,d=t[0],i=t[1],u=t[2],l=0,s=[];l<d.length;l++)c=d[l],Object.prototype.hasOwnProperty.call(o,c)&&o[c]&&s.push(o[c][0]),o[c]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(f&&f(t);s.length;)s.shift()();return a.push.apply(a,u||[]),r()}function r(){for(var e,t=0;t<a.length;t++){for(var r=a[t],n=!0,d=1;d<r.length;d++){var i=r[d];0!==o[i]&&(n=!1)}n&&(a.splice(t--,1),e=c(c.s=r[0]))}return e}var n={},o={38:0},a=[];function c(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,c),r.l=!0,r.exports}c.e=function(e){var t=[],r=o[e];if(0!==r)if(r)t.push(r[2]);else{var n=new Promise((function(t,n){r=o[e]=[t,n]}));t.push(r[2]=n);var a,d=document.createElement("script");d.charset="utf-8",d.timeout=120,c.nc&&d.setAttribute("nonce",c.nc),d.src=function(e){return c.p+"static/js/"+({27:"cancel.account.delete",28:"delete.request.confirmation",29:"expired.password",30:"inactive.account",31:"login",33:"mfa",34:"mfa.apps",35:"mfa.enrollment",36:"multi.factor",37:"pending.deletion"}[e]||e)+"."+{0:"7b4a730f",1:"ecd059d2",2:"21d56a68",3:"cea6d11b",4:"cadadbb4",5:"3d08c149",6:"d8a5952c",7:"de2c8faa",8:"5b996d8e",9:"0192baf0",10:"20b061ba",11:"851154bb",12:"580d5c64",13:"5d355b37",14:"1c6c374d",15:"4dec04bb",16:"2e08c2ba",17:"7ed8fd31",18:"1534ec28",19:"a4a8301e",20:"1ec03e2b",21:"ca067d80",22:"11b45caf",23:"c2b1c618",24:"20e1a100",25:"bab3c863",26:"2d8db227",27:"dbbc4023",28:"61960e86",29:"4ba19127",30:"da09d2ff",31:"4f30fd11",33:"9feac6d3",34:"83e26a79",35:"6d9e39a4",36:"71d4bda2",37:"c0d9b0be",40:"862d7dd4",41:"b149bfbc",42:"397012e1",43:"b22d3b3d"}[e]+".chunk.js"}(e);var i=new Error;a=function(t){d.onerror=d.onload=null,clearTimeout(u);var r=o[e];if(0!==r){if(r){var n=t&&("load"===t.type?"missing":t.type),a=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+n+": "+a+")",i.name="ChunkLoadError",i.type=n,i.request=a,r[1](i)}o[e]=void 0}};var u=setTimeout((function(){a({type:"timeout",target:d})}),12e4);d.onerror=d.onload=a,document.head.appendChild(d)}return Promise.all(t)},c.m=e,c.c=n,c.d=function(e,t,r){c.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},c.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.t=function(e,t){if(1&t&&(e=c(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(c.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)c.d(r,n,function(t){return e[t]}.bind(null,n));return r},c.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return c.d(t,"a",t),t},c.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},c.p="https://aid-frontend.prod.atl-paas.net/atlassian-id/front-end/5.0.240/",c.oe=function(e){throw console.error(e),e};var d=this["webpackJsonpaid-frontend"]=this["webpackJsonpaid-frontend"]||[],i=d.push.bind(d);d.push=t,d=d.slice();for(var u=0;u<d.length;u++)t(d[u]);var f=i;r()}([])</script><script src="https://aid-frontend.prod.atl-paas.net/atlassian-id/front-end/5.0.240/static/js/39.9ab39e49.chunk.js"></script><script src="https://aid-frontend.prod.atl-paas.net/atlassian-id/front-end/5.0.240/static/js/main.7bf5bbce.chunk.js"></script></body></html>

 

  • OK, I think the problem is that you're mixing up two styles of GET calls for testcases.  You only need to provide the project key if you want to return ALL test cases for a project.  In that scenario you shouldn't provide a testcase key.

     

    For your scenario you want to return details about a single testcase and for that, you only need to provide the testcase key... so oddly enough, my first reply is probably right and this should work, although I can't test: https://campbellscientific.atlassian.net/rest/atm/1.0/testcase/I2-T2 

     

    Let me know how it goes?

     

     

    ------

     

    Ignore this.  I've just seen that project key is needed in the Cloud API and that must be what you're using.  I'll take a look and see if I can spot anything to help.

     

    ------

     

    Hi,

     

    According to the API, you don't need to provide the project key.  You only need the testcase key.

     

    Here's an example of a working GET call for me - I'm on the Server version of Zephyr Scale so it might be why ours look different:

     

    https://jira.xxxx.com/rest/atm/1.0/testcase/xxxx

     

    That would mean that your call would look like this:

     

    https://campbellscientific.atlassian.net/rest/atm/1.0/testcase/I2-T2

     

    Does that work?

     

1 Reply

  • MisterB's avatar
    MisterB
    Champion Level 3

    OK, I think the problem is that you're mixing up two styles of GET calls for testcases.  You only need to provide the project key if you want to return ALL test cases for a project.  In that scenario you shouldn't provide a testcase key.

     

    For your scenario you want to return details about a single testcase and for that, you only need to provide the testcase key... so oddly enough, my first reply is probably right and this should work, although I can't test: https://campbellscientific.atlassian.net/rest/atm/1.0/testcase/I2-T2 

     

    Let me know how it goes?

     

     

    ------

     

    Ignore this.  I've just seen that project key is needed in the Cloud API and that must be what you're using.  I'll take a look and see if I can spot anything to help.

     

    ------

     

    Hi,

     

    According to the API, you don't need to provide the project key.  You only need the testcase key.

     

    Here's an example of a working GET call for me - I'm on the Server version of Zephyr Scale so it might be why ours look different:

     

    https://jira.xxxx.com/rest/atm/1.0/testcase/xxxx

     

    That would mean that your call would look like this:

     

    https://campbellscientific.atlassian.net/rest/atm/1.0/testcase/I2-T2

     

    Does that work?