Opentok livestreaming broadcast request error - opentok

When I make a request to start live streaming broadcast to opentok api,
I have this error :
{
"message" : "session cannot be broadcasted when mantis not available. with code 400"
}
In below my request term with postman :
url request
https://api.opentok.com/v2/project/api_key/broadcast
header parameters
X-OPENTOK-AUTH : eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Accept : application/json
Content-Type : application/json
EDIT :
This query is run in the following context: a session with two stream published. The API key is present as well as the session id.

TokBox Developer Evangelist here.
Based on the error message, it looks like you're trying to start a broadcast with a session that's set to relayed mode. You must set the mediaMode to routed when creating a session so you can leverage OpenTok's media servers and use the broadcast feature.

Tokbox QA staff here.
You have to put your API Key in the request.
Assuming you're doing it, you cannot do that request like that. First of all, you must create a session, and then, start a broadcast on that session, providing some info inside the POST body:
https://tokbox.com/developer/rest/#start_broadcast
I hope this helps.

Related

How to perform a GET request after a POST request with web-sockets

I am currently trying to build a go API using gin for a web and mobile application. I am new to the world of WebSockets and Go so I was wondering how I would go about triggering a GET request from the client after a relevant POST request was made ie: the POST request contained the user's ID so the clients who require information regarding that user are properly updated. Currently, I have the POST and GET requests which do what I need them, but I'm a little lost about how to make the entire flow realtime using WebSockets.
I believe this example of server-sent-events should address the question. Once a POST handler has been called, send a flag to the GET endpoint via a channel and then send an event through there.

How to prevent autheticated user from sending similar request via POSTMAN?

I am developing a simple website using MEAN stack that gives a logged-in user a task to complete and sends a score to the backend corresponding to their performance on that task. User can skip to next task in which case no score is sent. Problem is: How can I differentiate between a user cheating and sending score via a POST request on POSTMAN (by changing POST values to increase score) and a POST request created by my frontend code. How to work around this problem?
Welcome to Stackoverflow, to check if the request is made by POSTMAN (so locally) or by your backend (called by your front end) you just have to check if the request IP is your server or not.
This is a WhiteList solution
MEAN Stack use NodeJS, so you can use :
request.connection.remoteAddress
EDIT :
You can put a special parameter in your header when send a request with your front OR your Postman, and you check it when you receive it

TrustPilot Create Invitation API always returns 415 response code

I'm trying to send a TrustPilot invitation using the Create Invitations API but no matter what I try, I get a response code of 415 and with no data returned, so it's virtually impossible for me to debug.
The URL I'm using is correct: https://invitations-api.trustpilot.com/v1/private/business-units/{businessUnitId}/email-invitations (where {businessUnitId} is my business ID)
I am sending a valid (and current) oAuth token in my header.
I am sending a POST request.
I have tested my details with other "Business user OAuth Token" APIs and everything works, so my details are definitely correct. It's just this create invitation API that's not working.
I've tried everything. I've submitted minimal details, a full request, somewhere in between, the example request in the API, and so on. Always a response code of 415.
I've set my "Invitation Settings" in the TrustPilot Business portal, and have even tried submitting those details with the request (ie. sender e-mail "noreply.invitations#trustpilotmail.com" and a valid reply-to e-mail that's been configured).
I've tried contacting the "Integration Engineers" at TrustPilot who after a few back and forth e-mails, also have no idea, which is VERY unsettling. So time for Stack Overflow.
I need to get this figured out, so any help would be great! Perhaps someone can provide a sample request that works in their application that I can try to duplicate in mine?
Http status code 415 (Unsupported Media Type) is returned when Content-Type: application/json is not passed. You need to make sure that this header is added and that the content you are passing in the post body is valid json.
If you are already doing this then I would need an example of a request you are sending to help you further.

Shopify webhook verification in parse

I am trying to get a shopify webhook to fill my customer class in parse.com, however something must go wrong. I don't know how to verify the parse response since Shopify sends this webhook out from it's ruby backend. I used requestbin to catch the webhook and I replicated a post request using postman to my parse url and everything works fine. Does anyone know how to debug requests like these? Is there a console in Parse where I can see all the incoming requests and the responses Parse.com sent back?
Try using Runscope for debugging webhooks. Full guide here: https://www.runscope.com/provider-guide/troubleshooting-webhooks - this is more than just a request bin. It's a full transparent proxy that will, like a bin, record the webhook notification, but will also pass it along to the intended destination (your webhook receiver) and record that response as well.

Sails.js authorization for socket requests

I'm trying to build a chat application based on sails.js. The url for messages from a specific chat looks like this:
/api/chat/:id/messages
When I request this url with XHR, it provides a session cookie and sails.js builds a session object. I can easily check user rights to read the messages from the specific chat.
However, I need to request this url with socket.io so that the client can subscribe to all future changes of the messages collection.
When I request this url with socket.io, no session cookie is set and the sails.js session is empty. So, I cannot check the user rights on the server-side.
I do understand that socket requests are not HTTP-requests. They don't provide any cookies on their own.
Is there any simple workaround?
I found a way to get the session object which was set while socket.io handshaking.
In your controller, you should do something like this:
myControllerAction: function(req, res) {
var session = req.session;
if (req.isSocket) {
var handshake = req.socket.manager.handshaken[req.socket.id];
if (handshake) {
session = handshake.session;
}
}
//session now contains proper session object
}
You can implement this in sails.js policy, and attach this policy to some controllers. But don't write you socket session into req.session! Otherwise, you'll get an error trying to respond to the client (original req.session is still used in some way). Instead, save it as req.socketSession or something like that.
please send a JSONP request from your application before sending a socket request,that will create a cookie and accepts socket requests.
You can do your initial login over the socket.post() instead of XHR, subsequent socket requests will be authorized.
alevkon,in the above mentioned method you have to implement the same in all the controllers,because you don't know which controller is accessed for the first time...but by sending just one jsonp request you can create a cookie between client and server,the same cookie is used until the next session.

Resources