GET works through postman, but returns org.springframework.web.HttpMediaTypeNotSupportedException in CLI - spring

Using spring I wrote a method that should return an array of json objects when GET is called. I checked through PostMan everything works, but when I try to do the GET using curl I get
{"timestamp":1503570488519,"status":415,"error":"Unsupported Media Type","exception":"org.springframework.web.HttpMediaTypeNotSupportedException","message":"Unsupported Media Type","path":"/audpro/report"}
This is the address for postman localhost:8080/audpro/report
My curl command
curl -X GET "http://localhost:8080/audpro/report" -H "accept:application/json"
Why is that?

Related

How to know if graphql returned an error when using curl?

HTTP GraphQl calls always return 200 - even if the response doesn't suite the request.
I'm trying to do a graphql call and understand if there's an error, like using $? and --fail but it doesn't help because of the always 200 response.
Even if graphql's output isn't according to input and contains error arrays, curl only cares about the http code, which is always 200.
Is there a way for curl to understand a graphql error? Like some kind of built in mechanism in to compare requested input to actual input and understand there's an error?
Perhaps I'm barking on the wrong tree here and should use some command line tool more dedicated to graphql? Thanks.
curl doesn't know anything in particular about GraphQL. You can pipe the output of curl to grep to check for the presence of errors and draw conclusions based on that as necessary.
ex:
curl --request POST \
--header 'content-type: application/json' \
--url http://localhost:4000/ \
--data 'your query data'| grep "errors"

Http POST requests on Heroku running Springboot app

I've successfully deployed my Springboot app on Heroku. I'm also able to make get request like :
curl GET 'heroku-url'
Correctly returns :
{"id":1,"user_id":1,"title":"rneptdqxen","image":"","price":0.0,"description":"Niente"}
but not POST, if I try this :
curl -X POST 'heroku-url -d '{}' '
An error is thrown :
empty string within braces in URL position 49
If I change heroku-url to 127.0.0.1:8080/..., build Springboot app locally then POST request works so I think that the request is correct, probably I'm missing something about quotes.
please try
curl -X POST -d '{}' 'heroku-url'

Load GeoJSON file into Apache CouchDB

I am working on Windows10 and tried to load a geojson file into my couchdb via the "curl" command and a POST request in the cmd which looks like that:
C:\Program Files\cURL\bin>curl -d #path-to-my-data\data.geojson -H "Content-type: application/json" -X POST http://127.0.0.1:5984/_utils/database.html?-dbName-
and then I get the following error:
{"error":"method_not_allowed","reason":"Only GET,HEAD allowed"}
On http://couchdb-13.readthedocs.org/en/latest/api-basics/ it is said, that "If you use the an unsupported HTTP request type with a URL that does not support the specified type, a 405 error will be returned, listing the supported HTTP methods."
When I try that with a PUT request, I get the same error.
I validated the json with jsonlint so this should not be the problem.
I tried several tutorials like "Three Steps to CouchDB Heaven …" or "Export & Import a Database with CouchDB" but none of them seems to work.
So I am not sure, where the problem is. Do I need to make changes in my geojson file, or something else?
thanks for your help
The needed curl command just looks like that:
curl -H "Content-Type: application/json" -X POST http://localhost:5984/db -d #C:\Users\Name\Desktop\data.geojson

Curl to Ajax Http Request

How do I convert this curl command to ajax http request?
curl --insecure -h 'content-type' -d '<payload></payload>' https://ourback.end.servers/context-path.aspx
This is working in curl, but every time we access it via our ajax request, we encountered SSL3 wrong version number.
Thank you guys.

Cannot get imgur v3 api request to authorize using curl or other bash utility

I'm trying to scrape some public data from imgur.com using the v3 imgur api but whenever I make a request using curl I'm getting a 401.
This is how I'm calling the API (using this example from the example python app) -
curl -F "Authorization=Client-ID <my_client_id_provided_by_registering_my_app>" https://api.imgur.com/3/gallery/hot/viral/0.json
I've also tried
curl -F "client_id=<my_client_id>" https://api.imgur.com/3/gallery/hot/viral/0.json
So my question is, what format is the imgur api expecting for the auth header and how can I leverage it using curl or some other common bash utility?
The switch -F (or --form) is for sending HTTP forms. What you should use instead is -H (--header):
curl --header "Authorization: Client-ID $YOUR_ID" https://api.imgur.com/3/gallery/hot/viral/0.json

Resources