Firefox Add-on RESTClient - How to send data-binary file in the request? - rest

I am trying to use RESTClient Firefox add on to post something equivalent to this:
curl -s -S -X POST -H "Content-type: application/zip" \
--data-binary #./cluster-config.zip \
http://${JOINING_HOST}:8001/admin/v1/cluster-config
The idea is using this Firefox add-on (RESTClient) to debug my stuff until it works. But I am stuck because I don't find the way to add a file to the request (equivalent to --data-binary parameter of curl)
How can I include a file in the request in RestClient Firefox add-on?

Related

Reporters for Flutter integration testing

I am looking for examples of integrations among Flutter Integration library and test management tools like TestRail or Xray.
For Cypress and other browser automation tools I can find plenty of solutions but for Flutter integration basically nothing.
For Xray, there's no tutorial yet. However, it should be fairly simple.
Run your tests using flutter test and pass the --machine argument to generate a JSON report.
Use the junitreport package to generate a JUnit XML report.
Then you can add it to your command as such:
flutter test --machine | tojunit -o junit.xml
If you redirect this to a file, then you have the report that you can submit to Xray for example.
For Xray server/datacenter, you need to call the REST API endpoint, something like:
curl -H "Content-Type: multipart/form-data" -u username:password -F "file=#junit.xml" http://yourserver/rest/raven/1.0/import/execution/junit?projectKey=JIRAPROJECTKEY
For Xray on Jira Cloud, the syntax is slightly different. You have to make an authentication request first, and then do another submiting the JUnit XML report.
token=$(curl -H "Content-Type: application/json" -X POST --data '{ "client_id": "32A27E69B0AC4E5000000...","client_secret": "d62f81eb9ed859e1....." }' https://xray.cloud.getxray.app/api/v2/authenticate)
curl -H "Content-Type: text/xml" -X POST -H "Authorization: Bearer $token" --data #"junit.xml" https://xray.cloud.getxray.app/api/v2/import/execution/junit?projectKey=XTP

Can't download using Nexus 3 REST API and CURL

I'm trying to download the latest snapshot dependency of a zip on Nexus 3 (version 3.22.1-02) from a command line using curl:
curl -u username:password -X GET "https://mynexusserver/service/rest/v1/search/assets/download?sort=version&repository=snapshotsrepo&maven.groupId=mygroup&maven.artefactId=myartefact&maven.extension=zip" -H "accept: application/json" -o myartefact.zip
This request is similar to this example: http://help.sonatype.com/repomanager3/rest-and-integration-api/search-api#SearchAPI-DownloadingtheLatestVersionofanAsset but no result is returned, myartefact.zip is empty.
However with the same URL, my artefact is downloaded from a web browser or with gradle.
With curl the following command line is working fine, returning the list of all snapshot versions of my artefact:
curl -u username:password -X GET "https://mynexusserver/service/rest/v1/search/assets?sort=version&repository=snapshotsrepo&maven.groupId=mygroup&maven.artefactId=myartefact&maven.extension=zip" -H "accept: application/json" -o myartefact.zip
Downloading the artefact directly is working fine as well with a command line like:
curl -u username:password "https://mynexusserver/repository/snapshotsrepo/mygroup/batchfactory/myversion-SNAPSHOT/myartefact-myversion-mytimestamp.zip" -H "accept: application/json" -o myartefact.zip
Verbose logs (-v option) show the artefact is found (I get HTTP/1.1 302 Found message) but nothing is downloaded.
Using wget doesn't work any better, I can't even query the list of snapshot version of the artefact.
Am I missing something?
Thanks #Zeitounator, after adding "-L" the command line works fine. Considering code 302 this feels obvious now...
Nexus documentation should also probably be updated to add the "-L" option.

curl no URL specified using POST

From a shell, I'm trying to use the REST API for Fedora Commons to upload a binary to a particular location using curl:
curl -X PUT --upload-file image.jpg -H "Content-Type: image/jpeg" -H "http://localhost:8080/rest/TestUpload/newexcel"
The error I'm getting:
curl: no URL specified!
Following instructions from here:
https://wiki.duraspace.org/display/FEDORA471/RESTful+HTTP+API
-H is for extra header to include in the request when sending HTTP to a server and you should not use it before the url.
You probably need to do curl -X PUT --upload-file image.jpg -H "Content-Type: image/jpeg" http://localhost:8080/rest/TestUpload/newexcel

Mashape multipart-form POST request

I have a POST method in my API which uses multipart encoded form data. I have set up the correct header and data settings so that the mashape web interface generated the following curl:
curl -X POST --include 'https://sslavov-text-analytics-v1.p.mashape.com/news' \
-H 'Authorization: Basic ***********' \
-H 'X-Mashape-Key: ************' \
-H 'Content-Type: multipart/form-data' \
-F 'file=#sample.docx' \
-F 'meta={"documentType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document"};type=application/json'
Basically i'm trying to upload a file with a simple paragraph of text for processing. The curious part is that when I run this exact curl in a bash script, everything works smoothly, but when I try to run it through mashape, it says either 400 Bad Request or 500 Internal Server Error
In my particular case, these errors are generated when I don't pass correct form or headers. So my question is: Is there an error in the curl syntax or should I keep looking for the error on server side?
EDIT: I figured out what the problem was. -F 'file=#sample.docx' was passed before -F 'meta....' and that was causing the 500 Internal Server Error So now the question is: Is there any way to specifically arrange the order of the form fields (because mashape rearranges them aplhabetically)?

HTTP request equivalent of lb web-client import --full

How can I achieve the same functionality as lb web-client import --import file.csv --full http://service-uri with an HTTP request made with a tool like cURL?
If you want to update data, you can use:
curl -i -X POST -H "Content-Type: text/csv" --data-binary #file.csv http://service-uri
or if you want to replace data, you can use:
curl -i -X PUT -H "Content-Type: text/csv" --data-binary #file.csv http://service-uri