I have installed Magento 2 Server on one system with the system IP Address as Domain name and have installed Kong API Gateway on another system with default port id 8001. I have used curl -i -X POST --url http://localhost:8001/services --data 'name=testMagento' --data 'url=http://<IP ADDRESS OF SYSTEM>' to register magento services. To register end points I have used curl -i -X POST --url http://localhost:8001/services/testMagento/routes --data 'hosts[]=localhost' --data 'paths[]=/customer/account/login/referer/<key for login>' --data 'strip_path=false' --data 'methods[]=GET'. I need help on checking whether the requests being forwarded through Kong or not.
Related
From my computer the query via postman to my endpoint works, it returns the expected result.
but the code generated by "code snippet" does not work, what could be the cause ?
--That code doesnt work. But in postman yes (same laptop)
curl --location --request POST 'https://service' \
--header 'Ocp-Apim-Subscription-Key: myKey' \
--header 'Content-Type: audio/mpeg' \
--data-binary '#/path/audio_test.mp3'
Error: curl: (28) Failed to connect to <service> port 443: Timed out
To check that it is not a problem with my end, I tried another service that works in postman and the code generated by postman through "code snippet" works as well.
-- That works in postman and in my consol --
curl --location --request POST 'https://´service' \
--header 'Key: myKey' \
--header 'Content-Type: application/json' \
--data-raw '{"text":"myText",
"language": "en"
}
'
its return the expected result
Does anyone have any idea where I could look? Thanks
curl: (28) Failed to connect to port 443: Timed out
This will likely be a connection error either due to the client context (application/terminal) or the client host (the device itself). I assume the second request doesn't try to hit the same location or it was ran from another context.
Check your connection first and then troubleshoot from your way up. To do so, in the same exact place you're running your curl run the following:
telnet service 443
Where service is the endpoint you are using in the request. If that still gives the same error then the issue is down to a networking problem. Check from other clients, check VPNs or other applications that could be causing the blockage.
I am trying to connect to MicroStrategy REST API via curl in order to obtain the session state.
I have tried a PHP code using this example https://community.microstrategy.com/s/article/Library-REST-API-Login-PHP?language=en_US.
I get the following error:
{"code":"ERR009","message":"The user's session has expired, please reauthenticate","ticketId":"d2a5595614634adba2bb07e5b15bedc9"}
I've also tried to call the API directly from curl on Windows command line.
curl -X POST "http://localhost:8080/MicroStrategyLibrary/api/auth/login"
-H "accept: application/json" -H "Content-Type: application/json"
-d "{\"username\":\"Administrator\",\"password\":\"myPassword\",
\"loginMode\":1,\"maxSearch\":3,\"workingSet\":10,\"changePassword\":false,
\"newPassword\":\"string\",\"metadataLocale\":\"en_us\",
\"warehouseDataLocale\":\"en_us\",\"displayLocale\":\"en_us\",
\"messagesLocale\":\"en_us\",\"numberLocale\":\"en_us\",\"timeZone\":\"UTC\",
\"applicationType\":35}"
I do not get any response for this call.
What is the reason for this error?
While trying to use encryption/decryption feature of spring cloud config server with Pivotal Cloud Foundry's p-config-server service which is configured with a symmetric key for encryption, I am getting a 403 forbidden response which calling /decrypt on config server .
I am able to call the /encrypt endpoint successfully for encrypting values using below sample curl -
curl --location --request POST 'https://config-xxxx.apps.xxx.com/encrypt' \
--header 'Authorization: bearer <cf oauth_token here>' \
--header 'Content-Type: text/plain' \
--data-raw 'sample data'
But when trying to decrypt those values using /decrypt, I am getting 403 Forbidden error -
{
"error": "access_denied",
"error_description": "invalid issuer"
}
Sample curl for decryption -
curl --location --request POST 'https://config-xxxx.apps.xxx.com/decrypt' \
--header 'Authorization: bearer <cf oauth_token here>' \
--header 'Content-Type: text/plain' \
--data-raw '<encrypted value from previous step>'
In pivotal's config server documentation though there are reference to /encrypt but nothing related to /decrypt pivotal config server
Any pointers ?
In the Pivotal/Tanzu Spring Cloud Services (commercial product), the /encrypt API is exposed to anyone with the admin scope or to anyone that is a Space Developer in the space of the service.
The /decrypt endpoint is not exposed specifically, so you're not allowed to access with the same credentials, hence why you're seeing a 403.
My quick read of the code is that you'd need a token with scope config_server_<guide>.read to access that endpoint. Where <guid> is the config server's service guide (run cf service --guid <name> to obtain the guide).
To make that work, you'd need to get a token from the bound service or a service key, the latter is easier:
Run cf create-service-key <service_instance> decrypt-key
Run cf service-key <service_instance> decrypt-key
Run export TOKEN=$(curl -vv <access_token_uri> -d 'grant_type=client_credentials' -d 'client_id=<client_id>' -d 'client_secret=<client_secret>' | jq -r .access_token) where the values in <...> are from the output of #2.
Run curl -vv '<uri>/decrypt' -H "Authorization: bearer $TOKEN" -H 'Content-type: text/plain' -d '<encrypted-value>'
These depend on a Bash shell. You can do them on Windows, but the commands will vary. It also uses jq to make extracting the token easier. You could split the command in step #3 into two steps, fetching with curl and manually exporting TOKEN.
I have installed Eclipse Hono 1.1.1 Kubernetic cluster using Helm as per the below instructions.
https://hub.helm.sh/charts/eclipse-iot/hono
Initially I tried to create a tenant using the below command
curl -X POST "http://servername:28080/v1/tenants/DEFAULT_TENANT123" -H "accept: application/json" -H "Content-Type: application/json"
But then I got the Resource not found error.
And then as per the instructions in the How do i run curl command from within a Kubernetes pod
curl -X POST "http://ServiceName:Serviceport/v1/tenants/DEFAULT_TENANT123" -H "accept: application/json" -H "Content-Type: application/json"
Again it dint work..!!!
I tried the following command to enter into the device registry pod
kubectl exec -it honohelmdeploy-service-device-registry-0 -- sh
And inside the device registry pod, I tried to run the above command and still it dint work.
I am not sure what should be the Host and Port while using the below command
curl -X POST "http://HOST:PORT/v1/tenants/DEFAULT_TENANT123" -H "accept: application/json" -H "Content-Type: application/json"
I tried using device registry service name/ device registry pod name as hosts.
I tried using device registry ports
I tried using my server name / localhost as hosts..
I tried using 28080 as ports..
But I was not able to create a Tenant. Please assist.
Edited with the screeshot for kubectl get svc command
Ok, it seems like you have installed Hono to minikube without any loadbalancer running. You can see this from the EXTERNAL-IP column which contains <pending> for all of Hono's (externally visible) service endpoints.
You need to start minikube tunnel in order for these endpoints to be exposed via a loadbalancer as described in the chart's README. You should be able to run the minikube tunnel command either before or after having installed Hono to the cluster. Once the loadbalancer is running, the EXTERNAL-IP addresses should be bound and you should be able to access the service endpoints.
I am automating some continuous delivery processess that use openshift 3.5. They work fine from a command line, but I can hardly find any documentation of how the oc commands map to the OCP REST API. I've figured out how talk to the API and use what it directly offers. For example, I have a line:
oc process build-template -p APPLICATION_NAME=worldcontrol -n openshift | oc create -f - -n conspiracyspace
That takes a template named "build-template" from "openshift" namespace and processes it, piping the resulting definition to build a few objects like application image, into another namespace. I would appreciate an example of how this could be expressed in http request terms.
edit
Following #Graham's hint, here is what I got. First request is getting the contents of the template:
curl -k -v -XGET -H "User-Agent: oc/v3.5.5.15 (linux/amd64) openshift/4b5f317" -H "Authorization: Bearer ...." -H "Accept: application/json, */*" https://example.com/oapi/v1/namespaces/openshift/templates/build-template
Then apparently the oc client expands the parameters internally, and feeds the result into the POST:
curl -k -v -XPOST -H "Content-Type: application/json" -H "User-Agent: oc/v3.5.5.15 (linux/amd64) openshift/4b5f317" -H "Accept: application/json, */*" -H "Authorization: Bearer ...." https://example.com/oapi/v1/namespaces/openshift/processedtemplates
Run the oc command with the option --loglevel=10. This will show you what REST API calls it makes underneath and thus you can work out what you need to do to do the same thing with just the REST API. Do note that certain things may be partly done in the oc client, rather than delegating to a REST API endpoint call.
I did this, and at the very end of the output from the CLI, I saw this:
service "trade4-65869977-9d56-49a5-afa2-4a547df82d5c" created
deploymentconfig "trade4-65869977-9d56-49a5-afa2-4a547df82d5c" created
When piping to oc create -f -, then, the CLI must be inspecting the resulting template and creating each object in the objects array. No evidence of those calls were outputted to my command window, other than the two "created" statements.
So to fully automate this through the REST API, we would still need to parse that objects array returned by processtemplates and POST to the appropriate endpoints, correct?