Getting INVALID_ARGUMENT error on Nest Battery Cam GenerateWebRtcStream command - webrtc

I'm trying to execute the sdm.devices.commands.CameraLiveStream.GenerateWebRtcStream command on a Nest Battery Cam which only support WebRTC streams and not RTSP anymore:
curl -X POST \
'https://smartdevicemanagement.googleapis.com/v1/enterprises/FOO/devices/BAR:executeCommand' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $AT" \
--data-raw '{
"command" : "sdm.devices.commands.CameraLiveStream.GenerateWebRtcStream",
"params" : {
"offerSdp" : "v=0\r\no=- 3846095231 3846095231 IN IP4 0.0.0.0\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0\r\na=msid-semantic:WMS *\r\nm=video 52697 UDP/TLS/RTP/SAVPF 97 98 99 100 101 102\r\nc=IN IP4 192.168.178.30\r\na=sendrecv\r\na=extmap:1 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=mid:0\r\na=msid:da672441-0269-4c8d-a30f-690e81947987 d7634d8f-f452-455c-bd6e-c5aa890b3433\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=rtcp-mux\r\na=ssrc-group:FID 3144836330 4019375712\r\na=ssrc:3144836330 cname:a5ec0936-9faa-48c5-9d06-e61020812f0b\r\na=ssrc:4019375712 cname:a5ec0936-9faa-48c5-9d06-e61020812f0b\r\na=rtpmap:97 VP8/90000\r\na=rtcp-fb:97 nack\r\na=rtcp-fb:97 nack pli\r\na=rtcp-fb:97 goog-remb\r\na=rtpmap:98 rtx/90000\r\na=fmtp:98 apt=97\r\na=rtpmap:99 H264/90000\r\na=rtcp-fb:99 nack\r\na=rtcp-fb:99 nack pli\r\na=rtcp-fb:99 goog-remb\r\na=fmtp:99 packetization-mode=1;level-asymmetry-allowed=1;profile-level-id=42001f\r\na=rtpmap:100 rtx/90000\r\na=fmtp:100 apt=99\r\na=rtpmap:101 H264/90000\r\na=rtcp-fb:101 nack\r\na=rtcp-fb:101 nack pli\r\na=rtcp-fb:101 goog-remb\r\na=fmtp:101 packetization-mode=1;level-asymmetry-allowed=1;profile-level-id=42e01f\r\na=rtpmap:102 rtx/90000\r\na=fmtp:102 apt=101\r\na=candidate:b5a862d0ae1ed7334dea68b94dfa8e6f 1 udp 2130706431 192.168.178.30 52697 typ host\r\na=candidate:7f6336d9b24b4d36e0c8e622fd79e141 1 udp 1694498815 79.20.79.217 52697 typ srflx raddr 192.168.178.30 rport 52697\r\na=end-of-candidates\r\na=ice-ufrag:6Uh1\r\na=ice-pwd:cLKAgmaZAA5i1Tw7BHJkLD\r\na=fingerprint:sha-256 18:34:6E:4B:DC:6E:3D:00:49:28:24:AB:F5:CB:7F:FC:3E:4A:AD:A7:DE:D9:29:6D:5A:7C:A3:0F:76:C8:BD:E4\r\na=setup:actpass\r\n"
}
}'
and I'm always receiving a generic error:
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT"
}
}
Does anyone have any idea what i'm doing wrong?

Solution
The fact is that I was missing the data channel (myPeerConnection.createDataChannel("dataSendChannel");) and the correct createOffer parameters ({offerToReceiveAudio:!0,offerToReceiveVideo:!0}).
The following code generates a correct SDP offer which is accepted by Google.
const myPeerConnection = new RTCPeerConnection
myPeerConnection.createDataChannel("dataSendChannel");
myPeerConnection.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0}).then(function(offer) {
return myPeerConnection.setLocalDescription(offer);
})
.then(function() {
console.log(myPeerConnection.localDescription.sdp + "\n");
})
.catch(function(reason) {
console.log("An error occurred, so handle the failure to connect");
});
Also pay attention: if you don't send the newline character in the end of the offer string, you will get the following error:
{
"error": {
"code": 500,
"message": "Internal error encountered.",
"status": "INTERNAL"
}
}

Related

Add button to forward message from channel in Telegram

I'm not quite sure it's possible but probably someone did that. Is it possible to use bot for appending button to message user forwarded to bot? I mean:
Admin posted a message in his channel.
Admin forwarded message to bot (assume bot added in channel).
Bot appends to original message in channel with button.
So the answer is yes - it can be done with editMessageReplyMarkup API method:
curl
--request POST \
--url https://api.telegram.org/bot{BOT_SECRET_TOKEN}/editMessageReplyMarkup \
--header 'Content-Type: application/json' \
--data '{
"chat_id": {CHANNEL_ID},
"message_id": {CHANNEL_MESSAGE_ID},
"reply_markup": {
"inline_keyboard": [
[
{
"text": "Hello world!",
"url": "https://google.com"
}
]
]
}
}'

Linkedin V1 update-comments-as-company api throws 500 error code

We are using Linkedin v1 api update-comments-as-company endpoint to post comments on behalf of company page managed by the user. Nowadays this endpoint throws 500 error response while trying to add comment.
Example request:
curl -X POST -H "Authorization: Bearer xxxx" -H "Content-Type: application/json" -H "x-li-format: json" 'https://api.linkedin.com/v1/companies/12345/updates/key=UPDATE-c12345-640455667889990765/update-comments-as-company' --data '{"comment": "Posting as a company!"}'
Response:
{
"errorCode": 0,
"message": "Internal service error",
"requestId": "OBVNKWRJDC",
"status": 500,
"timestamp": 1528183732917
}
Kindly help me to resolve this.

Fiware Orion context broker subscription notification issue

I'm using orion context broker GE image orion-psb-image-R5.4 version 1.7.0 and I registered a device entity in it , then i implemented in my raspberry pi simple python server script that listens to any incoming message and print it on the Pi's logs . then i sent a subscription message to the context broker to let my raspberry pi subscribe to its corresponding entity in the context broker. The issue is that whenever i update the condition attributes in the entity in the context broker , they're supposed to trigger a notification to the raspberry pi and then the server script in the PI print the notification in the Pi's logs . But what really happens is that the context broker may trigger the notification for several times and then suddenly stops sending any notification when any additional change is applied to the condition attribute , and on every attempt i make i retrieve the subscription status in the context broker and i find that there was a failure stated by the lastfailure attribute giving me the time of my last failed attempt.
I thought the problem could be the connection to my Pi or even in the server script itself but when i launched direct requests from my terminal to the raspberry pi , it prints the all messages immediately even when the update is made from a remote place . So i concluded that the problem is definitely with the context broker and the notification process of the subscription itself .
Here's the subscription request i made :
curl -v contextbrokeraddress:1026/v2/subscriptions -s -S --header "Fiware-Service: XYZ" --header "Fiware-ServicePath: /XYZ" --header 'Content-Type: application/json' \
-d #- <<EOF
{
"description": " Try",
"subject": {
"entities": [
{
"id": "Controller1",
"type": "Controller"
}
],
"condition": {
"attrs": [
"switch",
"datashow"
]
}
},
"notification": {
"http": {
"url": "http://raspberryPiaddress:8080"
},
"attrs": [
"switch",
"datashow"
]
},
"expires": "2040-01-01T14:00:00.00Z",
"throttling": 5
}
EOF
now when the switch attribute is updated with a different value , it may trigger the notification to the raspberry pi for the first time only but then fails on any following attempts.
this is the simple python script that listens to the incoming notifications and print it in its logs:
import socket
HOST, PORT = '', 8080
listen_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
listen_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
listen_socket.bind((HOST, PORT))
listen_socket.listen(1)
while True:
print "listening on port 8080"
client_connection, client_address = listen_socket.accept()
print "notified"
request = client_connection.recv(1024)
print request
client_connection.close()
And this is how the notification from the context broker is printed on the Pi's logs in its successful times:
listening on port 8080
notified
POST / HTTP/1.1
User-Agent: orion/1.7.0 libcurl/7.19.7
Host: raspberryPiaddress:8080
fiware-service: XYZ
Fiware-ServicePath: /XYZ
X-Auth-Token: token
Accept: application/json
Content-length: 208
Content-type: application/json; charset=utf-8
Fiware-Correlator: f48ced60-1069-11e7-b743-fa163e7c4daf
Ngsiv2-AttrsFormat: normalized
{"subscriptionId":"58cd49191e9c000de6ea89c7","data":[{"id":"Controller1","type":"Controller","switch":{"type":"command","value":"OFF","metadata":{}},"datashow":{"type":"string","value":"OFF","metadata":{}}}]}
And when the notification is not received on any following updates on the entity , i check that it was failure by retrieving the subscription status which states that a failure happened in the context broker on sending the notification at the exact time of my attempt. This the status i retrieve to check that:
[
{
"description": " Try",
"expires": "2040-01-01T14:00:00.00Z",
"id": "58cd49191e9c000de6ea89c7",
"notification": {
"attrs": [
"switch",
"datashow"
],
"attrsFormat": "normalized",
"http": {
"url": "http://ahmadpi.ddns.net:8080"
},
**"lastFailure": "2017-03-24T08:22:23.00Z",**
"lastNotification": "2017-03-24T08:22:18.00Z",
"lastSuccess": "2017-03-23T22:09:33.00Z",
"timesSent": 66
},
"status": "failed",
"subject": {
"condition": {
"attrs": [
"switch",
"datashow"
]
},
"entities": [
{
"id": "Controller1",
"type": "Controller"
}
]
},
"throttling": 5
}
]
the problem now seems to be relating to the context broker and the way the subscription/notification processes are handled inside it . Now, i want to know whether the problem regards the context broker image version that i used or whether it regards something else . I just want to know where's the problem and how it can be handled please and thanks so much.
Although I'm not fully sure as don't have all the inputs (specially, CB log traces), by "it worked well as I said but sometimes stops for some reasons" (see comments thread in the question post) I tend to think is some networking/connectivity problem, not directly related with Orion Context Broker.

PAYPAL REST API: How do you bill with a vaulted credit card

Using the PAYPAL REST API, I was able to successfully (1) Vault a credit card and (2) Lookup the vaulted credit card information.
After you lookup the Vaulted Credit Card and receive Paypal's response; however, do you re-use that response data to create a transaction in the future?
#How to Look up the Vaulted Credit Card
curl -v [link removed]/CARD-8TT93830P06829326KIOO3XI -H "Content-Type:application/json" -H "Authorization:Bearer O912TKmsB8WRsgdNrNrJAmlCqF5kLdEl.re3z4Kmp8M"
#Paypal's Response to the Lookup Request
{"id":"CARD-8TT93830P06829326KIOO3XI","valid_until":"2016-08-26T00:00:00Z","state":"ok","payer_id":"user12345","type":"visa","number":"xxxxxxxxxxxx0331","expire_month":"11","expire_year":"2018","first_name":"Joe","last_name":"Shopper","links":[{"href":"[link removed]/CARD-8TT93830P06829326KIOO3XI","rel":"self","method":"GET"},{"href":"[link removed]/CARD-8TT93830P06829326KIOO3XI","rel":"delete","method":"DELETE"}]}
I am looking for a curl command that would allow me to use the Vaulted Credit Card to bill monthly.
You would use the same /payment call, but switch out the card data for the credit_card_id.
For example;
{
"intent": "sale",
"payer": {
"payment_method": "credit_card",
"funding_instruments": [
{
"credit_card_token": {
"credit_card_id": "CARD-XXXXXXXXXXXXXX"
}
}
]
},
"transactions": [
{
"amount": {
"total": "7.47",
"currency": "USD"
},
"description": "This is the payment transaction description."
}
]
}
Or in cURL:
curl -v https://api.sandbox.paypal.com/v1/payments/payment -X POST -H "Content-Type:application/json" -H "Authorization:Bearer xxxxxxxxx" -d '{"intent":"sale","payer":{"payment_method":"credit_card","funding_instruments":[{"credit_card_token":{"credit_card_id":"CARD-9ND477057R590115SKIOT7OY"}}]},"transactions":[{"amount":{"total":"7.47","currency":"USD"},"description":"This is the payment transaction description."}]}'
There is some more information about this in the docs as well.

how set ajax call by rest api parse.com

I'm new in rest api and i'm trying to use the api rest to associate file to object:
curl -X POST \
-H "X-Parse-Application-Id: qS0KL*9lFLE**S3VMk" \
-H "X-Parse-REST-API-Key: nh3***MhcKJIfIt1Gm" \
-H "Content-Type: application/json" \
-d '{
"name": "Andrew",
"picture": {
"name": "...profile.png",
"__type": "File"
}
}' \
https://api.parse.com/1/classes/PlayerProfile
Can anyone explain me how to set the ajax call?And what is "name":"andrew"?Is this a column named andrew in my player profile?
This is my implementation of api,but the server responded me bad request 400:
$.ajax({
type: 'POST',
headers: {'X-Parse-Application-Id':'qS0KLMx5h9lFLG**yhM9EEPiTS3VMk','X-Parse-REST-API-
Key':'nh3G8D**hcKJIfIt1Gm','Content-Type': 'application/json'},
url: "https://api.parse.com/1/users",
data: {
"username": "francesco",
"picture": {
"name": "b3b47ce2-62dc-4861-a0ad-79cfffe9b07a-foto ste.jpg",
"__type": "File"
}
},
contentType: "application/json",
success: function(data) {
console.log(data );
},
error: function(data) {
console.log("ko" );
}
});
May the api -d is wrong in my implementation.What's means -d in curl?
The example in the guide shows how you can create a new PlayerProfile object and associate it with a File in a single request. Since you want to update an existing User (and not create a new one), you'll need to use the Update REST API request format. Use PUT instead of POST, then specify which user you're referring to by appending the object id to the endpoint URL: https://api.parse.com/1/users/{objectId}.