REST API URL for VMC PUSH - cloud-foundry

This question is regarding REST API URL for use with curl equivalent to VMC push for a new application.
I have referred the api documentation of cloud foundry at http://apidocs.cloudfoundry.com/http-apps for various REST API URL mapping to vmc commands. However, I did not find a REST API URL for pushing a new application. I have tried deploying a new application with the POST html request but that returns a 504 BAD GATEWAY response. below is the curl command:
curl --request POST http://api.cloudfoundry.com/apps --data #data.json --header "Authorization: bearer token"
Content of data.json are as follows:
{"name": "mywebapp45", "staging": {"model": "spring","stack": "java"}, "uris": [ "mywebapp45.cloudfoundry.com"], "instances": 1, "resources": {"memory": 256},"state": "STARTED"}`
and the web app archive is in the same directory from where I execute the curl command.
Any insight on this is much appreciated. Thanks a lot for the help in advance

Based on the language, I'd like you to try the cfoundry ruby client: rubygems.org/gems/cfoundry, the java client: github.com/cloudfoundry/vcap-java-client, or the Node.js client which can also be found in github.

Related

"error": "invalid_client" while using Django OAuth toolkit

I was following the steps mentioned in the documentation for django rest framework.
I'm not able to proceed from step 4.
As mentioned in the documentation,
curl -X POST -d "grant_type=password&username=<user_name>&password=<password>" -u"<client_id>:<client_secret>" http://localhost:8000/o/token/
I have changed the above variables with my values.
curl -X POST -d "grant_type=password&username=admin&password=admin123" -u "5hKeHNtF3EKy3uCpJqaAe3mU2bGZTgJhsKKxIuAQ:pbkdf2_sha256$390000$VFcCOjIZkBFObellddDgKA$DXovC1UiuxRQ0KN/lARIdQmXcj8dnoJofkznmkkqsZY=" http://localhost:8000/o/token/
I tried to import the curl on postman and Im getting this error
Then I tried running the curl on Insomnia testing tool, and I got the request configured as in the screenshot.
Then I click send and I got an error
SO i changed 'Content-Type' to 'Form URL Encoded'
Now I'm geting an error
{
"error": "invalid_client"
}
I tried running the curl in shell also, and I'm getting an invalid syntax error
I'm stuck with this and don't know how to proceed with this. Please lend me a hand.
Thanks in advance...
I was using the hashed value for client_secret instead of the actual value.
How to get actual client_secret actual value?
Answer:
While creating new application, copy the Client secret before saving
the values
https://github.com/jazzband/django-oauth-toolkit/issues/1193

Can I use curl to make a speech:recognize (Google Cloud Speech-to-text) request using a .json from Google Cloud Storage?

I'd like to be able to make a speech:recognize request on and with my own cloud-hosted resources, so I can simply log into the Google Cloud Platform console, run a command in the Cloud Shell, and see the results. Much like https://cloud.google.com/speech-to-text/docs/quickstart-protocol, except without making use of anything locally.
Not sure what other important info to share, but the .json and .flac files in my cloud have public read access.
How can I achieve this?
my request:
curl -H "Content-Type: application/json" https://speech.googleapis.com/v1/speech:recognize?key=[my-api-key] -d #https://storage.googleapis.com/[bucket]/[json-request-filename].json
the response:
Warning: Couldn't read data from file
Warning: "https://storage.googleapis.com/[bucket]/[json-request-filename].json",
Warning: this makes an empty POST.
{
"error": {
"code": 400,
"message": "RecognitionAudio not set.",
"status": "INVALID_ARGUMENT"
}
}
here's the .json hosted in google cloud storage:
{
"config": {
"encoding":"FLAC",
"sampleRateHertz": 16000,
"languageCode": "en-US",
"enableWordTimeOffsets": false
},
"audio": {
"uri":"gs://[bucket]/[audio-filename].flac"
}
}
No new info, but here's how it all looks the Google Cloud Platform Shell:
[my-account]#cloudshell:~ ([my-project])$ curl -H "Content-Type: application/json" https://speech.googleapis.com/v1/speech:recognize?key=[my-api-key] -d #https://storage.googleapis.com/[bucket]/[json-request-filename].json
Warning: Couldn't read data from file
Warning: "https://storage.googleapis.com/[bucket]/[json-request-filename].json",
Warning: this makes an empty POST.
{
"error": {
"code": 400,
"message": "RecognitionAudio not set.",
"status": "INVALID_ARGUMENT"
}
}
The -d flag in the curl command tells curl to read data from the filename right after it, and use that data as the body of the request. curl does not recognize a web URL as a valid file. curl can't read that JSON file, so it acts as if it were an empty file, and builds a request with an empty body. The request that's sent to the API doesn't have any information about that JSON file.
The speech API receives the request with an empty body, and can't do anything with it. The API doesn't even know that you specified a Google Cloud object in the curl command.
The speech:recognize method is documented at https://cloud.google.com/speech-to-text/docs/reference/rest/v1p1beta1/speech/recognize. It does not have any way to get the parameters it needs except from the body of the request. You can't tell it to go read those parameters from somewhere else, such as a URL or Google Cloud object. You have to include them in the request, so the program that builds the request needs to know them.
You can find your API key using the following code but you have to install gcloud using this link https://cloud.google.com/sdk/docs/install#linux
gcloud auth application-default print-access-token
curl -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json; charset=utf-8" --data "{
'input':{
'text':'I\'ve added the event to your calendar.'
},
'voice':{
'languageCode':'en-gb',
'name':'en-GB-Standard-A',
'ssmlGender':'FEMALE'
},
'audioConfig':{
'audioEncoding':'MP3'
}
}" "https://texttospeech.googleapis.com/v1/text:synthesize"

How to test OpenIm (ForgeRock) Request on Postman?

I have openIdm ForgeRock installed locally and I'am trying to go through the API Explorer etc. in order to see how to use the endpoints and the available endpoints.
From localhost:8080 where ForgeRock is running I can run/try a request. It works fine and I see the Response with Status 200 and its details.
When I try same Request URL on Postman, I get:
{
"code": 401,
"reason": "Unauthorized",
"message": "Access Denied"
}
In a way this makes sense for me as I'am not logged in in this case as directly via ForgeRock Server on localhost:8080. So how can I work around this to be able to run my tests also on Postman.
I tried the parameters username=xxx and password=xxx to the Request on Postman, but it keeps throwing the same error.
I also tried it on Postman as CURL request exactly how ForgeRock is using it, but it seems to have an issue with Authorization.
curl -X GET --header 'Accept: application/json' --header 'X-Requested-With: Swagger-UI' 'http://localhost:8080/openidm/managed/user?_queryId=query-all'
Any Idea please?
Fixed. Was actually simple... Had to add the following in the headers:
X-OpenIDM-Username
X-OpenIDM-Password
Value is by default: opendidm-admin for both.

wso2 api manager PUT method does not work in api store

Wso2 API Manager 1.10.0. PUT method does not work in API store.
GET, POST, DELETE methods work, but PUT dose not work.
Error,
Curl
curl -X PUT --header "Content-Type: application/json" --header "Accept: application/json" --header "Authorization: Bearer c6c90338514e561c8a02a7b6a1c96553" -d "{\"payment\":\"PAID\"}" "https://10.138.31.22:8243/Starbucks_API/1/order_1"
Request URL
https://10.138.31.22:8243/Starbucks_API/1/order_1
Response Body
<ams:fault xmlns:ams="http://wso2.org/apimanager/security">
<ams:code>900906</ams:code>
<ams:message>No matching resource found in the API for the given request</ams:message>
<ams:description>Access failure for API: /Starbucks_API/1, version: 1. Check the API documentation and add a proper REST resource path to the invocation URL</ams:description>
</ams:fault>
Response Code
403
Response Headers
{
"content-type": "application/xml; charset=UTF-8"
}
Resource given in the request is actually matching, which I mentioned in API.
Any help is appreciated.
Resource Definition
You are having two PUT with same URL. You can't have two different HTTP resource with same URL.

converting curl api call into restful api call

i am very new to the java EE.
I have built some simple restful client for calling rest api's from java using jersey framework.
I have one curl request which i have to call from java
curl -i -X POST 'https://{url}' -H 'Content-Type: application/x-www-form-urlencoded' -H "Accept: application/vnd.newbay.dv-1.8+json" -H "X-HTTP-METHOD-OVERRIDE: DELETE" -H "X-Client-Platform: SERVICES" -H "X-Client-Identifier: IL" --insecure --data 'path=%2FMy+Samsung+GT-I9082%2F20130822_172409.jpg&path=%2FMy+Samsung+GT-I9082%2F20130905_085407.jpg'
Here the paths of file are passed as form post in curl using --data.
Can anyone tell me how to call this api from my java program using jersey framework? I am having difficulty because of this --data part? how exactly i will pass that in my restful java client that i cant understand.
Also can anyone tell me how to pass form post --data part while calling the same api from soapUI?
In your cURL command, --data provides post data in a classic html form format. You shoud alrealy be aware of that because the content-type is explicit : application/x-www-form-urlencoded
Jersey can handle this encoding for you, using MultivaluedMapImpl.
see Sending Name Value Pair in POST using Jersey Client