Asterisk REST ARI snoop (cURL) - rest

I try to:
curl -v -u j123:j321 -X POST "http://localhost:8088/ari/channels/1421226074.4874/snoop?spy=SIP/695"
In response to receiving:
"message": "Invalid direction specified for spy"
I try to:
SIP/695; SIP:695, SIP#695, localhost#695, channel, channelName
It's all not working.
Call comes into the queue from sip-416 to queue_1 and distribute to 694. I need to connect 695 for wiretapping channel 1421226074.4874.
I only need to listen and not to whisper.
Help me please)

The error message is telling you what the problem is:
"message": "Invalid direction specified for spy"
The spy parameter is a direction for spying, not the channel to spy on (see reference documentation here). You've already specified the channel to snoop on in the URI path - you need to specify the direction of the media in the spy parameter.
As an aside, apparently the auto generated wiki isn't display enum values, which is unfortunate. We'll have to fix that.
For reference, here's the parameter in the Swagger JSON:
"name": "spy",
"description": "Direction of audio to spy on",
"paramType": "query",
"required": false,
"allowMultiple": false,
"dataType": "string",
"defaultValue": "none",
"allowableValues": {
"valueType": "LIST",
"values": [
"none",
"both",
"out",
"in"
]
}

Related

Batch create transcription always results in: The recordings URI contains invalid data

I would like to use Azure Speech Services Batch Transcription APIs to create a transcription of my audio file. I've already had success using the Speech Service SDK (for Node.js), but was interested in trying out one of the newer features available in v3.1 preview version of the api (displayFormWordLevelTimestampsEnabled), so I figured I had to do use the REST API service to do that.
Overall my problem is that for whatever input I've feed the Create Transcript API for contentUrls, I always end up getting the same error:
"error": {
"code": "InvalidData",
"message": "The recordings URI contains invalid data."
}
After a little digging, I found some tips through the Azure portal to use sox to handle transcoding the audio file in the specific format requested.
The specific format they mention in the portal documentation shows:
If you are using REST API, make sure that it uses one of the formats in this table:
Format
Codec
Bit rate
Sample Rate
WAV
PCM
256 kbps
16 kHz, mono
OGG
OPUS
256 kpbs
16 kHz, mono
With the sox specific commands being:
Activity
SoX command
Check the audio file format.
sox --i
Convert the audio file to single channel, 16-bit, 16 KHz.
sox -b 16 -e signed-integer -c 1 -r 16k -t wav .wav
I ran my mp3 through the second command and verified the file with the first, and the contents of the file looks like:
Input File : 'out5.wav'
Channels : 1
Sample Rate : 16000
Precision : 16-bit
Duration : 00:00:30.09 = 481488 samples ~ 2256.97 CDDA sectors
File Size : 963k
Bit Rate : 256k
Sample Encoding: 16-bit Signed Integer PCM
Finally, I uploaded the file to a public S3 bucket, to use as my content url for my request:
POST https://westus.api.cognitive.microsoft.com/speechtotext/v3.0/transcriptions
{
"contentUrls": [
"https://s3.us-west-1.amazonaws.com/xxxx/out5.wav"
],
"locale": "en-US",
"displayName": "Test"
}
Still it failed with the same error that I posted above. Any insights into what might be wrong? Thanks!
Update:
The answer below mentioned being able to reference a reports.json file on the Get Transcript/Create Transcript api call.
When I use the Create Transcript API my payload is:
{
"self": "https://westus.api.cognitive.microsoft.com/speechtotext/v3.1-preview.1/transcriptions/02815462-e9c0-4fdc-8bbe-7b0e78152f95",
"model": {
"self": "https://westus.api.cognitive.microsoft.com/speechtotext/v3.1-preview.1/models/base/c3b008fa-eb47-4f6d-a5b9-71dd37870bb7"
},
"links": {
"files": "https://westus.api.cognitive.microsoft.com/speechtotext/v3.1-preview.1/transcriptions/02815462-e9c0-4fdc-8bbe-7b0e78152f95/files"
},
"properties": {
"diarizationEnabled": false,
"wordLevelTimestampsEnabled": false,
"displayFormWordLevelTimestampsEnabled": false,
"channels": [
0,
1
],
"punctuationMode": "DictatedAndAutomatic",
"profanityFilterMode": "Masked"
},
"lastActionDateTime": "2022-09-13T23:37:09Z",
"status": "NotStarted",
"createdDateTime": "2022-09-13T23:37:09Z",
"locale": "en-US",
"displayName": "Test"
}
Calling the Get Transcript I see:
{
"self": "https://westus.api.cognitive.microsoft.com/speechtotext/v3.1-preview.1/transcriptions/02815462-e9c0-4fdc-8bbe-7b0e78152f95",
"model": {
"self": "https://westus.api.cognitive.microsoft.com/speechtotext/v3.1-preview.1/models/base/c3b008fa-eb47-4f6d-a5b9-71dd37870bb7"
},
"links": {
"files": "https://westus.api.cognitive.microsoft.com/speechtotext/v3.1-preview.1/transcriptions/02815462-e9c0-4fdc-8bbe-7b0e78152f95/files"
},
"properties": {
"diarizationEnabled": false,
"wordLevelTimestampsEnabled": false,
"displayFormWordLevelTimestampsEnabled": false,
"channels": [
0,
1
],
"punctuationMode": "DictatedAndAutomatic",
"profanityFilterMode": "Masked",
"error": {
"code": "InvalidData",
"message": "The recordings URI contains invalid data."
}
},
"lastActionDateTime": "2022-09-13T23:37:22Z",
"status": "Failed",
"createdDateTime": "2022-09-13T23:37:09Z",
"locale": "en-US",
"displayName": "Test"
}
And finally looking at the transcript files I'm getting an empty list:
{
"values": []
}
I see no reference to a reports.json, or any data populated here at all.
In many cases you can get a detailed error information by doing a GET on https://westus.api.cognitive.microsoft.com/speechtotext/v3.0/transcriptions/<transcription_id>/files and looking at the report.json that is referenced there.
If that doesn't help, you could post transcription id(s) of failed transcription so someone from the team (I am one of them) can look at the service logs.

WbCmd Movesense: Trouble With Putting Objects

I'm testing on Windows with PowerShell.
When I put simple types like bool, WbCmd works like expected.
PS> wbcmd --port TCP7044 --path /Component/Led --op put --opdatatype bool --opdata true
WbCmd Movesense:
{
"response": 200,
"responsestring": "HTTP_CODE_OK",
"operation": "put",
"uri": "/net/ECSI00000000/Component/Led",
"querytimems": 0,
"querytimens": 536100
}
But when I try to put an object, it "fails to find the data type."
PS> wbcmd --port TCP7044 --path /Component/Leds/0 --op get
WbCmd Movesense:
{
"response": 200,
"responsestring": "HTTP_CODE_OK",
"operation": "get",
"uri": "/net/ECSI00000000/Component/Leds/0",
"content": {
"IsOn": true,
"LedColor": [
0,
"Red"
]
},
"querytimems": 0,
"querytimens": 613500
}
PS> wbcmd --port TCP7044 --path /Component/Leds/0 --op put --opdatatype LedState --opdata '{ "LedState":
{ "IsOn": false, "LedColor": 0 } }'
WbCmd Movesense:
{
"response": 404,
"responsestring": "Failed to find data type LedState",
"operation": "put",
"uri": "/net/ECSI00000000/Component/Leds/0",
"querytimems": 3,
"querytimens": 3526200
}
How can I fix that or get more information about what happens in the background?
There are two led API's in the Movesense sensor. The simple /Component/Led with a true/false value (matching the single led in current Movesense sensor). The second LED API has beed added to support multiple / multicolor LED's that are found in other Movesense compatible devices.
For Movesense sensor I'd recommend using the simple API. However to put to the complex API using wbcmd, use the following command (I've tested and it works, did in Mac, that's why the port looks like that):
wbcmd --port /dev/cu.usbserial-AL01XHQC --path /component/leds/0 --op put --opdata '{"IsOn":true}'
Full Disclosure: I work for the Movesense team

Wiremock json stub for https calls

I wanted setup https call as json configuration stub in wiremock.
What are the additional configuration need top provide?
I have below json config
{
"id": "177a103d-85e4-4688-acd6-acc8a97ce085",
"name": "provider_rest_push",
"request": {
"url": "/user/profile",
"method": "POST",
"bodyPatterns": [
{
"equalToJson": "{\"type\":\"011\".....}",
"ignoreArrayOrder": true,
"ignoreExtraElements": true
}
]
},
"response": {
"status": 200,
"body": "{\"result........."}",
"headers": {
"Cache-Control": "must-revalidate,no-cache,no-store",
"Content-Type": "application/json",
"Server": "Jetty(8.1.15.v20140411)"
}
},
"uuid": "177a103d-85e4-4688-acd6-acc8a97ce085",
"persistent": true,
"insertionIndex": 5
}
Above perfectly work for http but NOT for https:
I get below when changed to https
[WARNING] Illegal character 0x16 in state=START for buffer HeapByteBuffer#35a693b9[p=1,l=262,c=8192,r=261]={\x16<<<\x03\x01\x01\x01\x01\x00\x00\xFd\x03\x03\x87\xEb\xEb\x8b0\xB7\x14...\x01\x03\x02\x03\x03\x02\x01\x02\x02\x02\x033t\x00\x00>>>ding: gzip, defla...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00}
[WARNING] badMessage: 400 Illegal character 0x16 for HttpChannelOverHttp#72ab37c7{r=0,c=false,a=IDLE,uri=-}
2020-03-17 12:53:14.631 Request received:
0:0:0:0:0:0:0:1 - POST /user/profile
I referred this answer but not sure the password for the second step in the first answer
i.e.
Import certification into keystore
keytool -import -trustcacerts -alias mock -file localhost.crt -keystore identity.jks
According to http://wiremock.org/docs/https/ you need to configure the httpsPort. This is done at startup, not at runtime so it seems that you can't use the JSON API for that. If you're running the standalone version of Wiremock you can provide the port by specifying the environment variable https-port, have a look at http://wiremock.org/docs/running-standalone/ for that.
In either case, make sure you take note of the certificate requirements at the bottom of http://wiremock.org/docs/https/.

LDAP passport strategy for Hyperledegr composer

I have been trying to use LDAP passport strategy for authentication in hyperledger composer rest server. I am using below configuration for ldap passport:
export COMPOSER_PROVIDERS='{
"ldap": {
"provider":"ldap",
"authScheme":"ldap",
"module":"passport-ldapauth",
"authPath":"/auth/ldap",
"successRedirect":"/",
"failureRedirect":"/",
"server":"{
"url":"ldap://localhost:389",
"bindOn":"cn=admin,dc=example, dc=com",
"bindCredentials":"*****",
"searchBase":"ou=admin,dc=example,dc=com",
}"
}
}'
While starting composer-rest-server with authentication its showing error
SyntaxError: Unexpected token
in JSON at position 210
at JSON.parse (<anonymous>)
at Promise.then (/home/mfgteg/.nvm/versions/node/v8.9.3/lib/node_modules/composer-rest-server/server/server.js:127:34)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
I got the correct format. Thanks to a link I found on IBM site
I used the following configuration :
export COMPOSER_PROVIDERS='{
"ldap": {
"provider": "ldap",
"authScheme": "ldap",
"module": "passport-ldapauth",
"authPath": "/auth/ldap",
"successRedirect": "/",
"failureRedirect": "/",
"server": {
"url": "ldap://localhost:389",
"bindDn": "cn=admin,dc=example, dc=com",
"bindCredentials": "*****",
"searchBase": "ou=admin,dc=example,dc=com"
}
}
}'
However I am yet to figure out what to mention in "callbackURL".
Use the variable provided below. Just change the successRedirect and credentials as per your configuration. Also in case you are running Client application on some other machine, you may need to change the localhost in url to your machine IP address.
Note : I have tested this with open LDAP configured.
COMPOSER_PROVIDERS='{
"ldap": {
"provider": "ldap",
"authScheme": "ldap",
"module": "passport-ldapauth",
"authPath": "/auth/ldap",
"successRedirect": "Where you want to redirect",
"failureRedirect": "/ldap",
"session": true,
"json": true,
"LdapAttributeForLogin": "cn",
"LdapAttributeForUsername": "cn",
"server": {
"url": "ldap://localhost:389",
"bindDN": "cn=admin,dc=hsc,dc=com",
"bindCredentials": "xxxxx",
"searchBase": "ou=users,dc=hsc,dc=com",
"searchFilter": "(cn={{username}})"
}
}
}'

wso2am API manager 2.1 publisher change-lifecycle issue

I deployed API Manager 2.1.0 and setup the api-import-export-2.1.0 war file described here. After importing my API endpoint by uploading a zip file the status=CREATED.
To actually publish the API I am calling the Publisher's change-lifecycle API but I am getting this exception:
TID: [-1234] [] [2017-07-06 11:11:57,289] ERROR
{org.wso2.carbon.apimgt.rest.api.util.exception.GlobalThrowableMapper}
- An Unknown exception has been captured by global exception mapper.
{org.wso2.carbon.apimgt.rest.api.util.exception.GlobalThrowableMapper}
java.lang.NoSuchMethodError:
org.wso2.carbon.apimgt.api.APIProvider.changeLifeCycleStatus(Lorg/wso2/carbon/apimgt/api/model/APIIdentifier;Ljava/lang/String;)Z
Any ideas on why?
I can get an access token (scope apim:api_view) and call this
:9443/api/am/publisher/v0.10/apis
to list the api's just fine.
I get a different acces_token (for scope: apim:api_publish) and then call
:9443/api/am/publisher/v0.10/apis/change-lifecycle
but get the above Exception. Here's the example:
[root#localhost] ./publish.sh
View APIs (token dc0c1497-6c27-3a10-87d7-b2abc7190da5 scope: apim:api_view)
curl -k -s -H "Authorization: Bearer dc0c1497-6c27-3a10-87d7-b2abc7190da5" https://gw-node:9443/api/am/publisher/v0.10/apis
{
"count": 1,
"next": "",
"previous": "",
"list": [
{
"id": "d214f784-ee16-4067-9588-0898a948bb17",
"name": "Health",
"description": "health check",
"context": "/api",
"version": "v1",
"provider": "admin",
"status": "CREATED"
}
] }
Publish API (token b9a31369-8ea3-3bf2-ba3c-7f2a4883de7d scope: apim:api_publish)
curl -k -H "Authorization: Bearer b9a31369-8ea3-3bf2-ba3c-7f2a4883de7d" -X POST https://gw-node:9443/api/am/publisher/v0.10/apis/change-lifecycle?apiId=d214f784-ee16-4067-9588-0898a948bb17&action=Publish
{
"code":500,
"message":"Internal server error",
"description":"The server encountered an internal error. Please contact administrator.",
"moreInfo":"",
"error":[]
}
Issue resolved. In apim 2.1 the publisher & store API versions changed.
In apim 2.0 I was using:
:9443/api/am/publisher/v0.10/apis
:9443/api/am/store/v0.10/apis
but in apim 2.1 they are:
:9443/api/am/publisher/v0.11/apis
:9443/api/am/store/v0.11/apis