using xray api with postman

Bruno Bernadet July 26, 2021

Hi

 

il try to use xray api with postman. i use your sandbox to create some tests and a project Validation

i am with a basic auth, i create a xray environnement (see the screenshot)

i try this query {{JIRA_BASEURL}}/rest/api/2/project/{{PROJECT_KEY}}

this is the result with a 404 error like if i can't see my project : {    "errorMessages": [        "Impossible de trouver un projet avec la clé 'VALIDATION'."    ],    "errors": {}}

Any idea where i am wrong ?

thanks

4 answers

1 accepted

0 votes
Answer accepted
Bruno Bernadet July 27, 2021

sorry i 've got it from atlassian site https://www.atlassian.com/developers/developer-showcase/xpandit.

it's a solution partner who propose a sandbox. all is site is a reference to jira so i made a confusion.

i have a postman collection but you are right from not could help me because it's out of your compagny scope. sorry fot that i don't realise the difference as i was following a link in your web site

0 votes
Manuel
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 31, 2024

Authentication to Xray server/dc REST API is made on top of Jira, therefore you use a username/password authentication; nowadays, as passoword you'll use a personal access token which provides more control, as detailed here.

Note: there seems to be some Postman resources/collections that allow you to exercise Xray APIs. The project seems a bit outdated but has many examples of invoking the APIs.

 

0 votes
Bruno Bernadet July 27, 2021

excuse me i forget to translate the error. I look for the value and it's ok i change it with another and i have always the 401 error

Status code is 200 | AssertionError: expected response to have status code 200 but got 401

i check the login and password and it's ok

David Bakkers
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 27, 2021

Hello @Bruno Bernadet 

I understand there is a language barrier, but you are going to have to be specific, as you are saying some very vague and jumbled things.

A 401 error is not a 404 error. Those mean totally different things.

An assertion error from Postman means you're doing something very, very wrong. It usually happens when variables are misused. I get a feeling that you're not really comfortable with using Postman.

Why not try just a plain GET request directly in your web browser, like this:

  1. Log into your Jira Server instance with your username and password.
  2. Once logged in, got to the Projects menu and select 'All Projects'
  3. From the list of Projects, find the one you're interested in and make a note of the key.
  4. Open a new tab in your web browser.
  5. In that tab's URL, type the GET request directly, in this format:

https://{your domain}/rest/api/2/project/{project key}

Jira should then tell you all the details about the project.

Please provide a screen grab of your web browser tab with all that information showing, like this:

Annotation 2021-07-27 193616.png

Bruno Bernadet July 27, 2021

as i say before i use the sandbox of atlassian for my test. i don't have the rights for the moment  in my firm for the tests in a real platform. i can't use curl because of the capcha and when i do asScreenshot 2021-07-27 132655.png you said i have a 401 error like you can see in the picture

David Bakkers
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 27, 2021

Hello @Bruno Bernadet 

Sorry, I don't think I can help you as I don't understand much of what you are doing.

I have no idea why you've put the word 'raven' in the middle of the Jira request URL. The URL in your screen grab is nothing like the one you said you were using in Postman, which you said was "{{JIRA_BASEURL}}/rest/api/2/project/{{PROJECT_KEY}}"

The only time I've seen the word 'raven' inside a REST API request is the old XRay Server v1 REST API calls, but that's a totally different thing for a totally different purpose and, as such, Jira Projects cannot be looked up via an XRay API endpoint.

I have never heard of Atlassian having a Jira 'sandpit' belonging to a company called xpand-it.com. Maybe that company doesn't allow access to the REST API of this Jira 'sandbox' that you say needs a 'captcha' to access.

Lastly, the error message on that page says that it was expecting OAuth credentials with cookies, which means Basic authentication with usernames + passwords will never work. Contact that company and ask them for more information as exactly what authentication method is required for whatever REST API of whatever system you are trying to access.

You seem to have lots of very different REST API systems, concepts and access methods confused. You might want to talk to a developer at your company first, to better understand how all this stuff works and how to use it.

Good luck with your efforts anyhow.

0 votes
David Bakkers
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 26, 2021

Hello @Bruno Bernadet 

The translation to English of that error is "Cannot find a project with the key 'VALIDATION' ", so it seems like you have formed the request incorrectly and supplied the word 'VALIDATION' as the Project key instead of the actual key.

You will need to look more closely in Postman as to how the variable {{PROJECT_KEY}} is given a value. If in doubt, provide the actual Project key instead of using a variable.

Suggest an answer

Log in or Sign up to answer