We are setting up a reporting feed to a client and, in testing out the endpoint, we are receiving different responses between cURL (command-line) and Postman. In Postman, the request goes through, just fine; we get a 200-OK back. However, when we send the request in cURL, we get the following response back curl: (60) SSL certificate problem: certificate has expired
With cURL
The cURL request looks like the following:
curl -i -H "content-type: application/json" -d '{"foo": [],"bar": [],"baz": []}' https://test.example.com/notARealEndpoint
With Postman
The Postman setup is hard to display, but it's code-conversion looks like:
cURL interpretation
curl --location --request POST 'https://test.example.com/not/aReal/Endpoint' --header 'Content-Type: application/json' --header 'Content-Type: text/plain' --data-raw '{"foo": [],"bar": [],"baz": []}'
*This, by the way, returns the same certificate has expired error when run in command line
HTTP interpretation
POST /not/aReal/Endpoint HTTP/1.1
Host: test.example.com
Content-Type: application/json
Content-Type: text/plain
{"foo": [],"bar": [],"baz": []}
Looks like the target server has an expired SSL certificate. The reason that postman is not raising an error couble be because of disabled SSL verification checks.
You can disable those checks in curl by using a --insecure or -k option.
eg:
curl https://expired.badssl.com
Will throw the same error that you are seeing.
versus
curl --insecure https://expired.badssl.com
will return an html response body.
Related
I am able to login my local (and remote server) with the following curl (which I generated using Postman)... and I can login successfully using another API Client (Rested) with the same params/headers/body that I am trying to use in Postman. I've turned off "SSL cert verification" and "Send Postman Token header" in settings (per other Stack Overflow answers).. but still getting an unauthorized response from server when using Postman (but not when using curl or Rested)
curl:
curl -X POST \ http://localhost:8080/api/user/login \ -H 'Accept:
application/json' \ -H 'Content-Type: application/json' \ -d '{
"email": "email#example.com",
"password": "examplemail**" }'
And here is my log..
I just solved my own Q.. and posting this answer because I've seen other questions re: curl working but postman not on SO and Postman communities. My solution was to check the Content-Length header and Connection headers. They were auto populating anyway, so after 'accepting' them as headers, the Postman request worked. Here is a screenshot of the headers that worked.
I am attempting to connect to the Rundeck API using CURL but I am getting a 401 Unauthorized error:
curl --insecure --location --request GET 'https://rundeck.example.com' --header 'Accept: application/json' --header 'X-Rundeck-Auth-Token: xyz'
401 Authorization Required
Authorization Required This server could not verify that
you are authorized to access the document requested. Either you
supplied the wrong credentials (e.g., bad password), or your browser
doesn't understand how to supply the credentials required.
Apache/2.2.15 (Oracle) Server at rundeck.example.com Port
80
If I try it using my username, it works.
curl --insecure --location -u 123456789 -p password --request GET 'https://rundeck.example.com' --header 'Accept: application/json' --header 'X-Rundeck-Auth-Token: xyz'
I created the auth token on Rundeck using my personal user that has admin privileges.
Please note that I have set up LDAP at web server level (httpd.conf) and control user access from there.
To access API you need to specify some action (for example: run a job, get metrics, etc.)
For example, get the instance metrics:
curl --location --request GET "http://yourhost:4440/api/34/metrics/metrics" --header "Accept: application/json" --header "X-Rundeck-Auth-Token: C8nVU5AhdzpQ8ucBeMG1ITFvSfaKCw6u"
Here you have a lot of examples.
In the code I inherited there is a REST call that sets up user permissions for a virtual host in a rabbitmq installation. On my developer box I have latest RabbitMQ server installed, 3.7.7. The client software uses a Spring RestTemplate to query the host. It generates a PUT request to http://localhost:15672/api/permissions/myhost/administrator with a payload of
{"read":".*","write":".*","configure":".*"}
and an HTTP header Content-Type:application/json;charset=UTF-8
This all looks reasonable to me - but the response is
HTTP/1.1 415 Unsupported Media Type
This code is years old, and I suspect it is my RabbitMQ installation that is too new for it, but I'd like to rather make the code future-proof than to install an RabbitMQ from 2015 ...
I have googled extensively on this issue but all I found was some bug about doubled headers in the rabbitmq client software that is not in use here. I traced it into apache httpclient classes and there is nothing on the sender side that smells.
Any suggestions what is wrong?
It turned out that the Apache HttpClient was adding a second content-type header to the message, caused the rejection on RabbitMQ Management plugin.
Yes, content type should not be applied
curl -s -i -u guest:guest -H "content-type: application/json" -H "content-type: application/json" -X POST --data '{"properties":{"delivery_mode":2},"routing_key":"program.*","payload":"{\"id\":\"123456\"}","payload_encoding":"string"}' 'http://127.0.0.1:15672/api/exchanges/%2F/my-exchange/publish'
return HTTP/1.1 415 Unsupported Media Type
Without content-type or just one :
curl -s -i -u guest:guest -H "content-type: application/json" -X POST --data '{"properties":{"delivery_mode":2},"routing_key":"program.*","payload":"{\"id\":\"123456\"}","payload_encoding":"string"}' 'http://127.0.0.1:15672/api/exchanges/%2F/my-exchange/publish'
return HTTP/1.1 200 OK
I have a question about how can I configure -H "Host: my.host.com" from gateway to my api.
I have the following logic:
I try to cover, for example, my-api.net via apiman-gateway.
For example, I can do the following direct call to my api like 'curl -X GET --header 'Accept: */*' -H "Host: www.google.com" 'http://my-api.net/accounts?accountNumber=12314123'.
Based on this call, my api will know, that my consumer is google for example. But once I try to make a call via apiman-gateway 'curl -X GET --header 'Accept: */*' -H "Host: www.google.com" 'http://apiman-gateway/GoogleOrganization/API/V1/accounts?accountNumber=12314123', the host is not possible to pass, and implementation of my api tells me that it does not know any host name like already deployed my-api.net. Probably someone can tell me how can I set up for example via policy, probably just to make a call from apiman-gateway to my api with the host parameters like above?
I am new to openstack, trying to use Ceilometer python API to pull some data from a testbed server, I am accessing the server from a remote site
the problem is that I cannot figure out how get the an authorization token
I used the following command
curl -i 'http://HOST:8774/' -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d/tokens auth": {"tenantName": "project", "passwordCredentials": {"username": "user", "password": "password"}}}'
But it does not give me anything,
curl -X GET -H "X-Auth-Token:$MY_TOKEN" http://HOST:8774/tokens
also does not give me any token
From your use of port 8774 I suspect you might be using DevStack. Try this
curl -s -X POST http://$OPENSTACK_KEYSTONE_HOST:5000/v2.0/tokens -d '{"auth": {"passwordCredentials": {"username":"my-username", "password":"my-password"}, "tenantName":"my-tenantName"}}
In DevStack Keystone (the auth service you get tokens from) is running on port 5000 by default. This may or may not be true in your case. Ask your friendly OpenStack operator what host (and port) Keystone is running on and put that in place of $OPENSTACK_KEYSTONE_HOST:5000