JIRA/Xray - Not able to import cucumber tests using curl due to error "The file is required!"

Nuno Oliveira
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 30, 2020

Hello,

We are trying to import cucumber tests that we already have developed into the Xray project that exists in our JIRA cloud.

We are following the information present on Importing Cucumber Tests - REST 

The authentication is done using the client_id/client_secret with the following command:

curl -H "Content-Type: application/json" -X POST --data '{"client_id": "<client_id>","client_secret": "<client_secret>"}' https://xray.cloud.xpand-it.com/api/v1/authenticate

which returns the authentication token.

Then we try to import an existing and simple feature file by using the rest api:

feature file.png

curl -H "Content-Type: multipart/form-data" -X POST -H "Authorization: Bearer <token>" -F "file=@<absolute path>/xray.feature" https://xray.cloud.xpand-it.com/api/v1/import/feature?projectKey=<our xray project key> -v

curl_response.png

The response is "The file is required".
We have tried multiple ways but the response is always the same and there's no clue regarding what's wrong.

Any help regarding this would be very appreciated.

Thanks,


Curl version:
curl 7.64.1 (x86_64-apple-darwin19.0) libcurl/7.64.1 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.39.2

2 answers

0 votes
Rogério Paiva - Xray Xporter
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.
January 13, 2022

Hi @Nuno Oliveira 

Please run the command from the folder where the feature file is located and without the path in the command line. I suspect that it could be something related to the file path.

Hi @Zakaria Boutami 

Please try to place the file argument between quotes, like this:

... -F "file=@features.zip" ...

If none of these works, it is best to contact Xray Support (http://Xraysupport.getXray.app) to share your configuration so that the support team can investigate further.

Thank you.

Kind regards,
Rogerio Paiva [Xray Support Team]

0 votes
Sergio Freire - Xblend
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.
September 3, 2021

Hi @Nuno Oliveira ,

that's weird. I'm unable to replicate it.

Were you able to overcome this?

Regards,

Sergio

Zacaries Benamiar January 4, 2022

Hi Sergio,

I'm experiencing the same problem:

curl -H "Content-Type: multipart/form-data" -F file=@features.zip -H "Authorization: Bearer <REMOVED>" https://xray.cloud.xpand-it.com/api/v1/import/feature\?projectKey\=<REMOVED>\&source\=<REMOVED> -v
* Trying 52.7.228.161:443...
* Connected to xray.cloud.xpand-it.com (52.7.228.161) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
* CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server did not agree to a protocol
* Server certificate:
* subject: CN=*.cloud.xpand-it.com
* start date: Dec 17 00:00:00 2020 GMT
* expire date: Jan 17 23:59:59 2022 GMT
* subjectAltName: host "xray.cloud.xpand-it.com" matched cert's "*.cloud.xpand-it.com"
* issuer: C=GB; ST=Greater Manchester; L=Salford; O=Sectigo Limited; CN=Sectigo RSA Domain Validation Secure Server CA
* SSL certificate verify ok.
> POST /api/v1/import/feature?projectKey=<REMOVED>&source=<REMOVED> HTTP/1.1
> Host: xray.cloud.xpand-it.com
> User-Agent: curl/7.77.0
> Accept: */*
> Authorization: Bearer <REMOVED>
> Content-Length: 15306
> Content-Type:  multipart/form-data; boundary=------------------------fe356ce82ce1f9af
>
* We are completely uploaded and fine
* Mark bundle as not supporting multiuse
< HTTP/1.1 400 Bad Request
< Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate
< Content-Type: application/json; charset=utf-8
< Date: Tue, 04 Jan 2022 16:25:15 GMT
< ETag: W/"21-9pZPaqO5pJmSaTVV6u0NXjAN8rg"
< Expires: 0
< Pragma: no-cache
< Retry-After: 60
< Surrogate-Control: no-store
< X-Powered-By: Express
< X-RateLimit-Limit: 60
< X-RateLimit-Remaining: 59
< X-RateLimit-Reset: Tue Jan 04 2022 16:26:15 GMT+0000 (Coordinated Universal Time)
< Content-Length: 33
< Connection: keep-alive
<
* Connection #0 to host xray.cloud.xpand-it.com left intact
{"error":"The file is required!"}%


vishwas kale
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 5, 2022

Try with v2 version 

token=$(curl -k -H "Content-Type: application/json" -X POST --data '{ "client_id": "X","client_secret": "Y" }' https://xray.cloud.getxray.app/api/v2/authenticate | tr -d '"')
curl -k -H "Content-Type: application/json" -X POST -H "Authorization: Bearer $token" --data @"merged-test-results.json" https://xray.cloud.getxray.app/api/v2/import/execution/cucumber

Replace X and Y with your client_id & client_key

Like Zacaries Benamiar likes this
Zacaries Benamiar August 9, 2022

Hi @vishwas kale

The endpoint you are referring to is different, but I tried with v2 for https://xray.cloud.getxray.app/api/v2/import/feature and it worked!

Thanks!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events