Watson Speech to Text asynchronous http interface - curl / java cannot Register a callback - speech-to-text

i am trying to register a callback url with watson STT as below (curl script only) and getting 400 error. node.js process listening on port 3000 to handle request. am i missing something?. Thanks much in Advance.
curl -X POST -u "apikey:xxxxxxxxxxxxxx9xRhxjF2QOqssMkUhLkzl0" "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/register_callback?callback_url=http://localhost:3000/results&user_secret=my_secret_key"
{
"code": 400,
"code_description": "Bad Request",
"error": "unsuccessful response from the server"
}

Related

Keeping getting server and network error when trying to retrieve data from my LoopBack api

When I open my loopback API in Firefox try and use the GET commands for the controllers on my user and plant collection from my mongodb
I get this response from the Curl
curl -X 'GET' \
'http://[::1]:3000/users?filter=%7B%0A%20%20%22offset%22%3A%200%2C%0A%20%20%22limit%22%3A%20100%2C%0A%20%20%22skip%22%3A%200%2C%0A%20%20%22order%22%3A%20%22string%22%2C%0A%20%20%22where%22%3A%20%7B%0A%20%20%20%20%22additionalProp1%22%3A%20%7B%7D%0A%20%20%7D%2C%0A%20%20%22fields%22%3A%20%7B%0A%20%20%20%20%22userID%22%3A%20true%2C%0A%20%20%20%20%22email%22%3A%20true%2C%0A%20%20%20%20%22phoneNumber%22%3A%20true%2C%0A%20%20%20%20%22plantsRegistered%22%3A%20true%0A%20%20%7D%0A%7D' \
-H 'accept: application/json'
And this response from the Request URL
http://[::1]:3000/users?filter=%7B%0A%20%20%22offset%22%3A%200%2C%0A%20%20%22limit%22%3A%20100%2C%0A%20%20%22skip%22%3A%200%2C%0A%20%20%22order%22%3A%20%22string%22%2C%0A%20%20%22where%22%3A%20%7B%0A%20%20%20%20%22additionalProp1%22%3A%20%7B%7D%0A%20%20%7D%2C%0A%20%20%22fields%22%3A%20%7B%0A%20%20%20%20%22userID%22%3A%20true%2C%0A%20%20%20%20%22email%22%3A%20true%2C%0A%20%20%20%20%22phoneNumber%22%3A%20true%2C%0A%20%20%20%20%22plantsRegistered%22%3A%20true%0A%20%20%7D%0A%7D
And I get this message when I open up the firefox inspector
Source map error: Error: NetworkError when attempting to fetch resource.
Resource URL: http://[::1]:3000/explorer/swagger-ui.css
Source Map URL: swagger-ui.css.map
Within the server response it appears as
TypeError: NetworkError when attempting to fetch resource.
I also got a server error(
Error: Internal Server Error) with the response body(I tried opening the API on chrome and got this error. I got this error on Firefox as well
{
"error": {
"statusCode": 500,
"message": "Internal Server Error"
}
}
I am not sure how to fix this so I'm hoping I could find a potential solution on here

Angular post request refused, but nodejs post request works

I have an express app which listening on port 5000 like this:
app.listen(5000, "0.0.0.0, ()=>'Server started on' + 'port ' + 5000).
When i try to send a post request by node script using axios its response me 200.
axios.post('http://localhost:5000/api/auth/login', {})
But i when i try sending the same request using Angular HttpClient.Post its gives me an error : "Connection refused"
this.http.post(environment.apiUrl + '/auth/login', {username, password, role})
The problem started when i tried to run all of these components on a remote server.
it works for me fine when i tried to run all of these components on my local machine.
Any ideas why it should happen?
I would appreciate your help!

How do I connect React native app with node js?

I have already created backend using node js for sigin & signup page. Now I want to connect to node js . But i have no idea how to do that. I want to connect both react native with my node js. Can you help me ?
simply as how we do for web apps.
here is an example of error reporting
export default async function (body) {
console.log(JSON.stringify(body))
const res = await fetch(`${host}/api/report`, {
method: 'POST',
body: JSON.stringify(body),
headers: {
'Content-Type': 'application/json',
},
})
const { message } = await res.json()
if (message) return Toast({ message: message });
else return Toast({ message: 'network error' });
}
I have used fetch to send a POST request to my nodejs server
use API tool like postman or other and make your your nodejs APIs works fine and then connect to your React Native app as above.
You can use ngrok to connect Node with react-native. Run this command:
npm i ngrok -g # installing it globally
Then open another terminal. Run:
ngrok http 3000 # the port you are running on node
Then it will show an alternative link that you can use to test with your Node.
Note: if ngrok http 3000 doesn't work, try ngrok http -region us 3000.
The available ones are us, eu, ap, and au. In my case eu worked for me.
Then copy the link generated e.g. http://8074-129-205-124-100.eu.ngrok.io and test your backend if it displays APIs.
If the link works then you can use it with fetch. Uploading json data to send to MongoDB as the case maybe.

Koajs and curl with Content-Encoding: gzip,deflate

I am looking for simple example of exchange data between client (using curl) and Koajs server with Content-Encoding: gzip,deflate.
More detail: the client have log file. Client compress the log file and send the log file to server. Server decompress the log file and get the content.
Please give me both curl command and Koajs code.
Thank you.
When you wanna send compressed request to server using curl you can do so using
curl -v -H "Content-encoding: gzip" -X POST -H 'Content-Type:
application/json;charset=UTF-8' --data-binary #youdataFile.gzip
your_endpoint.com
and if you wanna decompress that request in koaServer, I don't really know about that but would surely like to know. As even I'm in need to know that
This is how I decompress data in Koa Server using zlib
var zlib = require('zlib');
zlib.unzip(buffer, (err, buffer) => {
if (err) return console.log(err);
var dataString = buffer.toString();
});

Self-hosted Parse Platform RESTful API access

I'm using Parse for some quick MVP app development to prove some concepts. Everything is working fine and I'm simply trying to extend the abilities of our app by setting up some 3rd party integrations etc.
I would like to access my Cloud Code functions via the RESTful api, as documented here
I've changed the server address, but have no luck connecting and pulling the data.
I am using Node.js to connect to the REST api, which is being hosted on Heroku.
var options = {
host: 'https://###############.herokuapp.com',
port: 443,
path: '/parse/functions/'+req.param('text'),
method: 'POST',
headers: {
'X-Parse-Application-Id': '##############',
'X-Parse-REST-API-Key': '###########'
}
};
https.get(options, function(resp){
resp.on('data', function(chunk){
//do something with chunk
res.send(chunk)
});
}).on("error", function(e){
console.log("Got error: " + e.message);
res.send(e)
});
So far no luck. Any suggestions?
Hard to tell what exactly is wrong without seeing the Parse Server configuration, the Cloud Code function, and more importantly the server's response, but here's what worked for me:
curl -X POST -H "X-Parse-Application-Id: XYZUASDASDA" -H
"X-Parse-REST-API-Key: XYZUASDASDA" -H "Content-Type:
application/json" -d '{}'
http://localhost:3000/parse/functions/averageStars
Result: {"result":"Hello"}
Here's my test Cloud Code function:
Parse.Cloud.define('averageStars', function(request, response) {
response.success('Hello'); });
As a quick test, I suggest:
Try using CURL
Try the test function above

Resources