Agora Composite Recording start returns empty sid - agora.io

When I try to start composite recording, it returns empty sid resulting in not be able to start the recording.
When I try individual recording, it works fine.
Am I missing something?
This is my code:
func startRecording() {
let body : [String : Any] = [
"uid": uid,
"cname": channelName,
"clientRequest": [
"token": token(),
"recordingConfig": [
"maxIdleTime": 30,
"streamMode": "standard",
"streamTypes": 2,
"channelType": 0,
"subscribeUidGroup": 1
],
"storageConfig": [
"secretKey": MyAWS.secretKey,
"vendor": 1,
"bucket": MyAWS.buketName,
"accessKey": MyAWS.accessKey,
"region": 10,
"fileNamePrefix": [
channelName
],
"extensionParams": [
"sse":"kms"
]
]
]
]
AF.request("https://api.agora.io/v1/apps/\(KeyCenter.AppId)/cloud_recording/resourceid/\(resourceId)/mode/mix/start",
method: .post,
parameters: body,
encoding: JSONEncoding.default,
headers: headers)
.authenticate(username: username, password: password)
.responseDecodable(of: CloudRecordingStartedResp.self, completionHandler: { response in
print("cloud_recording.start")
switch response.result {
case .success(let data):
print("resourceId:\(data.resourceId)\nsid:\(data.sid)")
self.sid = data.sid
case .failure(let error):
let str: String? = String(data: response.data!, encoding: .utf8)
print("error:\(error)\ndata:\(str)")
}
})
}
Thank in advance.

streamMode was unnecessary.
Deleted, then it worked!

Related

to generate client code from httpsnippet(npm)

I am not able to get headers in the output while generating the client code
const snippet = new HTTPSnippet({
method: 'GET',
url: 'http://mockbin.com/request',
headers: {
'content-type': 'Application/json',
}
});
const options = { indent: '\t' };
const output = snippet.convert('shell', 'curl', options);
console.log(output);
output
[Error [HARError]: validation failed] {
errors: [
{
keyword: 'type',
dataPath: '.headers',
schemaPath: '#/properties/headers/type',
params: { type: 'array' },
message: 'should be array'
}
]
}
expected: - headers should be the part of the curl rather than this error
The validation message says that headers should be an array.
HAR Docs (found in httpsnippet);
<headers>
This object contains list of all headers (used in <request> and <response> objects).
"headers": [
{
"name": "Accept-Encoding",
"value": "gzip,deflate",
"comment": ""
},
{
"name": "Accept-Language",
"value": "en-us,en;q=0.5",
"comment": ""
}
]

How to get all values where a certain Key matches in Dataweave 2.0?

Payload :
[
{
"Contacts": "123456,098765",
"Emails" : ""
},
{
"Contacts": "ABC123",
"Emails" : ""
}
]
How can I get a list of all emails from the below array of objects where the contact Id matches from each row in the payload? (Expected output below)
Variable accConts
{
"queryResponse": [
{
"Email": "test123#test.com",
"SalesforceId": "123456"
},
{
"Email": "test#test.com",
"SalesforceId": "098765"
},
{
"Email": "ABC#test.com",
"SalesforceId": "ABC123"
}
]
}
Expected Output:
[
{
"Contacts": "123456,098765",
"Emails" : "test123#test.com, test#test.com"
},
{
"Contacts": "ABC123",
"Emails" : "ABC#test.com"
}
]
HTH..
%dw 2.0
output application/json
var qResp ={
"queryResponse": [
{
"Email": "test123#test.com",
"SalesforceId": "123456"
},
{
"Email": "test#test.com",
"SalesforceId": "098765"
},
{
"Email": "ABC#test.com",
"SalesforceId": "ABC123"
}
]
}
---
payload filter ($.Contacts != null) map using (iter = $$) {
"Contacts" : $.Contacts,
"Emails": (qResp.queryResponse filter (payload[iter].Contacts contains $.SalesforceId)) reduce ((item,acc = "") -> (acc ++ "," ++ item.Email)[1 to -1]
)
}
I accepted Salim Khan's answer as he guided me in the right direction and the logic to get emails worked. I just needed to rework the map logic,
payload map (row, index) -> {
"Contacts" : row."Contacts",
"Emails" : (qResp.queryResponse filter (row."Contacts" contains $.SalesforceId)) reduce ((item,acc = "") -> (acc ++ "," ++ item.Email)[1 to -1]
),
}
Hopefully this comaprision helps
Wanted to add a slightly more succinct solution to show another approach.
%dw 2.0
output application/json
var qResp =
{
"queryResponse": [
{
"Email": "test123#test.com",
"SalesforceId": "123456"
},
{
"Email": "test#test.com",
"SalesforceId": "098765"
},
{
"Email": "ABC#test.com",
"SalesforceId": "ABC123"
}
]
}
---
payload map (value) ->
{
'Contacts':value.Contacts,
'Emails': qResp.queryResponse[?(value.Contacts contains $.SalesforceId)]..Email joinBy ", "
}

React native sending image to server using formdata

I have a problem sending a picture to a server, that's like the default approach, but it does not seem to work.
var source = '/Users/alexx/Library/Developer/CoreSimulator/Devices/44F0FA92-4898-4CFB-862E-4E5EC4C8AB28/data/Containers/Bundle/Application/34BCE695-4B4F-472F-AB5C-F2336AC45273/DoorLock.app/123.jpg';
const form = new FormData();
form.append('image', {
uri: source,
type: 'image/jpg',
name: '123.jpg',
});
const data = () => {
fetch(api ,{
method: 'POST',
body: form,
})
that's the response i get from the server:
{
"_bodyBlob": {
"_data": {
"__collector": [
Object
],
"blobId": "78B18938-15BF-4F18-B3C8-1EB30A24D9F8",
"name": "test.html",
"offset": 0,
"size": 192,
"type": "text/html"
}
},
"_bodyInit": {
"_data": {
"__collector": [
Object
],
"blobId": "78B18938-15BF-4F18-B3C8-1EB30A24D9F8",
"name": "test.html",
"offset": 0,
"size": 192,
"type": "text/html"
}
},
"bodyUsed": false,
"headers": {
"map": {
"connection": "keep-alive",
"content-length": "192",
"content-type": "text/html",
"date": "Mon, 02 Nov 2020 22:57:21 GMT",
"server": "PythonAnywhere"
}
},
"ok": false,
"status": 400,
"statusText": undefined,
"type": "default",
"url": api
}
Although this python code works perfectly and gets a correct response
img = {'file':('123.png', open('the path to the pic/123.png', 'rb'), 'image/png)}
post(api, files = img)
is there any way to get this working or its the server side problem that can't receive the correct arguments?
Adding "file://" to the beginning of the source string fixed the problem.
so the src looks like
var source = 'file:///Users/alexx/Library/Developer/CoreSimulator/Devices/44F0FA92-4898-4CFB-862E-4E5EC4C8AB28/data/Containers/Bundle/Application/34BCE695-4B4F-472F-AB5C-F2336AC45273/DoorLock.app/123.jpg';
then it fetches perfectly, hope it helps anybody who tries to send a local image using formdata, the summary looks like this now
const form = new FormData();
form.append('file', {
uri: source,
name: '123.jpg',
fileName: 'file', //optional
});
fetch(uri,{
method: 'post',
body: form,
})
.then(response => {
console.log("image uploaded")
console.log(response)
})
.catch(console.log);
In Formdata when you pass files, you need to pass 3 parameters where
key expected from the backend (in your case image).
It will be an object which has three properties named name, type, and uri where type is the mime type (ex: image/jpeg).
name of the file
Eg:
data.append("FilePath",{
name:"image.png",
type:"image/png",
uri:"content://com.camera/image.png"
},image.png)

Agora Unable to Start Cloud Recording

options1 = {
'method': 'POST',
'url': 'https://api.agora.io/v1/apps/' + appID + '/cloud_recording/resourceid/' + resourceId + '/mode/2/start',
'headers': {
'Content-Type': 'application/json',
'Authorization': 'Basic XXX'
},
body: JSON.stringify({
"cname": "lol",
"uid": "1",
"clientRequest": {
"token": token,
"recordingConfig": {
"maxIdleTime": 30,
"streamTypes": 2,
"channelType": 0,
"videoStreamType": 0,
"transcodingConfig": {
"height": 640,
"width": 360,
"bitrate": 500,
"fps": 15,
"mixedVideoLayout": 1,
"backgroundColor": "#FF0000"
},
"subscribeVideoUids": [
"123",
"456"
],
"subscribeAudioUids": [
"“123”",
"“456”"
],
"subscribeUidGroup": 0
},
"recordingFileConfig": {
"avFileType": [
"hls"
]
},
"storageConfig": {
"accessKey": config.writeAccessKeyId,
"region": 3,
"bucket": config.bucket,
"secretKey": config.writeSecretAccessKey,
"vendor": 1,
"fileNamePrefix": [
"directory1",
"directory2"
]
}
}
})
};
request(options1, function (error, response, body) {
if (error) throw new Error(error);
console.log(response.statusCode);
I referred to the Agora's Cloud Recording API. Authentication and resourceId work fine. The response.statusCode is always 404. Unable to locate the error. I tested on Postman and the URL is not working as well. May I know if any attributes are entered wrongly? Does the user have to join the channel before the recording can start?
In your url, you have specified mode/2/start.
It should be mode/mix/start.
You can refer the documentation here for more information:
https://docs.agora.io/en/cloud-recording/cloud_recording_api_rest?platform=All%20Platforms#parameters-1
Does cloud recording work for Android and iOS as well?

BigQuery + javascript (tabledata.insertAll)

Here is my code:
function runQuery(){
var json = JSON.stringify({"string": "eight", "number": "8", "id": "8"});
var body = {
"kind": "bigquery#tableDataInsertAllRequest",
"rows": [
{
"insertId": "8",
"json": json
}
]
};
var request = gapi.client.bigquery.tabledata.insertAll({
'projectId': project_id,
'datasetId': 'newTest',
'tableId': 'newTable',
'content': body
});
request.execute(function(response){
console.log(response);
});
}
But this code return error: No records present in table data append request. (400)
Can somebody help me?
Problem solved:
var request = gapi.client.bigquery.tabledata.insertAll({
'projectId': projectId,
'datasetId': datasetId,
'tableId': tableId,
"kind": "bigquery#tableDataInsertAllRequest",
"rows":[
{
"insertId": "10",
"json": {"id": "10", "string": "ten", "number": "10"}
}
]
});
Spent a lot of time on the same issue.
dbepcepk's answer resulted in the error:
"Error: Invalid JSON payload received. Unknown name "rows": Cannot bind query parameter. 'rows' is a message type. Parameters can only be bound to primitive types."
Here is how I got around it:
Note the JSON Key "resource" defining the TableDataInsertAllRequest object
const request ={
"projectId": projectId,
"datasetId": datasetId,
"tableId": tableId,
"resource":{
"kind": "bigquery#tableDataInsertAllRequest",
"skipInvalidRows": false,
"ignoreUnknownValues": false,
"templateSuffix":"",
"rows": [{"json": {"test":true}]
}
}
client.tabledata.insertAll(
request,
(err, data) => {
if (err) {
reject(err);
} else {
resolve(data);
}
});
You can't append data to the sample data set. Create your own to perform your inserts.