curl no URL specified using POST - rest

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

Related

Correcting a simple malformed CURL request

I have a fairly straightforward curl GET request to a server that has a functioning endpoint but which is giving me a 400 error. I'm honestly not sure what's causing the error.
Here's the request:
curl -v -g -X GET "https://pokemon.server.com/api/set_data?scan_next=true&instance=City%20Downtown&coords='[{"lat":120,"lon":45}]'" -H 'Content-Type:application/x-www-form-urlencoded' -H 'Accept:application/json' -u 'user:password'
The API spec is here: https://github.com/RealDeviceMap/RealDeviceMap/wiki/7.-API-Calls
And I know it's not an authentication issue because this request works
curl -v -X GET 'https://pokemon.server.com/api/set_data?reload_instances=true' -H 'Accept:application/json' -u 'user:password'

Cannot import grafana dashboard via grafana HTTP API

I am trying to import existing json file using HTTP API, but the 'curl' command throwing the error.
I am using the below command to import existing json file,
curl --user admin:admin "http://localhost:3000/api/dashboards/db" -X POST -H "Content-Type:application/json;charset=UTF-8" --data-binary #/u04/sys_monitor/my_Metrics.json
If i run the above command, it is throwing the error like "[{"fieldNames":["Dashboard"],"classification":"RequiredError","message":"Required"}]"
I tried to run the below command,
curl --fail --insecure --user admin:admin --request "POST" "http://localhost:3000/api/dashboards/db" --header "Content-Type: application/json" --data-binary #/u04/sys_monitor/my_Metrics.json
For the above command execution i am getting the error like,
curl: (22) The requested URL returned error: 422 Unprocessable Entity
Where i am doing wrong, kindly assist me,
The below comment is working but not updated the dashboard in grafana,
curl --user admin:admin -vvv "http://localhost:3000/api/dashboards/db" -X POST -d #My_Metrics.json -H 'Content-Type: application/json'

MarkLogic ingest JSON from external API

I am using Marklogic 9 and try to ingest data from external source into MarkLogic. I made an REST API on port 8031. When I try to execute the following curl command:
curl --anyauth --user admin:admin -i -X POST -d https://services7.arcgis.com/21GdwfcLrnTpiju8/arcgis/rest/services/Geluidsbelasting/FeatureServer/0/query?where=1%3D1&outFields=*&outSR=4326&f=json
-H "Content-type: application/json" -H "Accept: application/json" \
'http://localhost:8031
After executing this statement I receive the error:
Curl: URL is not specified
Can you please help me out!
Many thanks
Erik
Your -d parameter has special characters that are not escaped. Try putting quotes around your -d url. It will prevent your command from getting truncated and misinterpreted at & signs..
HTH!

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

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

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?