Twilio Outgoing call using Twiml - How do I wait for voicemail? - twilio

I have successfully configured Postman to make a test call using variables in the Twiml parameter. However, when it goes to voicemail, the message has already played through. For example, in a longer Say message, the beginning is cut off in the recorded message.
How would I wait for voicemail "answer" when there is no human answer?
curl --location --request POST 'https://api.twilio.com/2010-04-01/Accounts/AC05917c014691f7d218d20XXXXXXX/Calls' \
--header 'Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXZjExZDIwM2IzOTYwMjUzYQ==' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'To=1484xxxxxxx' \
--data-urlencode 'From=1610xxxxxxx' \
--data-urlencode 'Twiml=<?xml version="1.0" encoding="UTF-8"?> <Response> <Pause length="2"/><Say voice="Polly.Salli-Neural">" Hello world
</Say> <Pause length="2"/> </Response>'

Related

Get Statewise Location report from Google Ads

I want to get the report as shown here https://prnt.sc/oG7ms7tOdVfH
The input is Country = USA
Date from and Date to
But this gives non US states and it doesnt summarize the resuly by state names (not the state IDs)
Can anyone help me to get the REST API?
curl "https://googleads.googleapis.com/v10/customers/${CUSTOMER_ID}/googleAds:searchStream" \
--header "Content-Type: application/json" \ --header "developer-token: ${DEVELOPER_TOKEN}" \
--header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \
--header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \
--data '{ "query": "
SELECT
PERFORMANCE COST
FROM LOCATION
WHERE
COUNTRY = 'USA' AND
segments.date BETWEEN 20220101 AND 20220430
" }'

JRXML upload from Jenkins give HTTP-500 but works elsewhere

I am using Jasper REST API to publish reports on Jasper Server.
Below are the scenarios:
When I upload the .JRXML file from POSTMAN and then create a report from POSTMAN using the JRXML. It works.
When I upload the .JRXML file from POSTMAN and then create a report from Jenkins using the JRXML. It works.
When I upload the .JRXML file from Jenkins and then create a report from Jenkins using the JRXML. It gives me HTTP 500 Error
When I upload the .JRXML file from Jenkins and then create a report from Jenkins using the JRXML. It gives me HTTP 500 Error.
I have even tried with cURL and it works fine. Its just the Jenkins where it gives the error. I have tried a lot of things but it has no outcome.
cURL from POSTMAN:
#To upload JRXML
curl --location --request POST 'https://server-url/jasperserver-pro/rest_v2/resources/Reports/' \
--header 'Content-Type: application/jrxml' \
--header 'Content-Disposition: attachment; filename=form.jrxml' \
--header 'Content-Description: Uploaded jrxml file POSTMAN' \
--header 'Authorization: Basic %Base64 Creds%' \
--data-binary 'report-templates/form.jrxml'
#To create report
curl --location --request POST 'https://server-url/jasperserver-pro/rest_v2/resources/Reports' \
--header 'Content-Type: application/repository.reportUnit+xml' \
--header 'Authorization: Basic Base64 Creds' \
--data-raw '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<reportUnit>
<description/>
<label>new_report1</label>
<permissionMask>1</permissionMask>
<uri>/Reports</uri>
<version>0</version>
<dataSourceReference>
<uri>/Data_Sources/mysql</uri>
</dataSourceReference>
<alwaysPromptControls>true</alwaysPromptControls>
<controlsLayout>popupScreen</controlsLayout>
<inputControlRenderingView/>
<jrxmlFileReference>
<uri>/Reports/form.jrxml</uri>
</jrxmlFileReference>
</reportUnit>'
JenkinsFile:
pipeline {
agent any
parameters{
string(defaultValue: 'form5_report', description: 'Provide the name of JRXML file, without the extension that should be used to create report. Defaults to form5_report.', name: 'JRXML_FILE', trim: false)
string(defaultValue: "${params.JRXML_FILE}.${BUILD_NUMBER}", description: 'Provide a name for the generated report. By default, it would be same as JRXML with BUILD_NUMBER.', name: 'TESTUNIT', trim: false)
}
environment{
JRXML_FILE = "${JRXML_FILE}.jrxml"
def XML = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<reportUnit>
<description/>
<label>${TESTUNIT}</label>
<permissionMask>1</permissionMask>
<uri>/Reports</uri>
<version>0</version>
<dataSourceReference>
<uri>/Data_Sources/mysql</uri>
</dataSourceReference>
<alwaysPromptControls>true</alwaysPromptControls>
<controlsLayout>popupScreen</controlsLayout>
<inputControlRenderingView/>
<jrxmlFileReference>
<uri>/Reports/${JRXML_FILE}</uri>
</jrxmlFileReference>
</reportUnit>"""
}
stages {
stage('File Check') {
steps {
script {
String url = "https://server-url/jasperserver-pro/rest_v2/resources?q=${JRXML_FILE}"
def (String code) =
sh(script: "curl -s -o /dev/null -w '%{http_code}' -H 'Authorization: Basic base64 creds' $url", returnStdout: true).trim().tokenize("\n")
if(code == '200'){
stage ('Create Report'){
sh '''
curl --location --request POST 'https://server-url/jasperserver-pro/rest_v2/resources/Reports' \
--header 'Content-Type: application/repository.reportUnit+xml' \
--header 'Authorization: Basic base64 creds' \
-d "$XML"
'''
}
}else{
stage('SCM Checkout'){
git branch: 'branchname',
credentialsId: 'git',
url: 'repo_URL'
}
stage('Upload JRXML File to JasperServer'){
sh '''
curl --location --request POST 'https://server-url/jasperserver-pro/rest_v2/resources/Reports/' \
--header 'Content-Type: application/jrxml' \
--header "Content-Disposition: attachment; filename=${JRXML_FILE}" \
--header 'Content-Description: Uploaded jrxml file' \
--header 'Authorization: Basic base64 creds' \
--data-binary "$WORKSPACE/${JRXML_FILE}"
'''
}
stage('Create Report'){
sh '''
curl --location --request POST 'https://server-url/jasperserver-pro/rest_v2/resources/Reports' \
--header 'Content-Type: application/repository.reportUnit+xml' \
--header 'Authorization: Basic base64 creds' \
-d "$XML"
'''
}
}
}
}
}
}
}
What am I doing wrong? Any help is greatly appreciated.
Alright, so I got it working.
Apparently, I was unaware of the fact that when referencing/passing a file with --data-binary option, you need to prepend it with the '#' symbol.
Therefore changing line no.61 from --data-binary "$WORKSPACE/report-templates/${JRXML_FILE}" to --data-binary "#$WORKSPACE/report-templates/${JRXML_FILE}" did the trick. Otherwise, it was just saving the absolute path as the content of the file and not the actual XML data.

Configure client_id as mandatory param for password grant type

What is the proper way to make client_id a mandatory param for password grant type?
Using this request I want to make client_id a mandatory value and let the OAuth2 framework to compare it with the result returned into the method loadClientByClientId
curl --location --request POST 'http://localhost:8080/engine/oauth/token' \
--header 'Authorization: Basic YWRtaW46cXdlcnR5' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'username=admin' \
--data-urlencode 'password=qwerty' \
--data-urlencode 'client_id=some_value' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'scope=read_profile'
What is the best way to implement this?
You could try implementing a custom OAuth2RequestValidator with method validateScope(TokenRequest tokenRequest, ...) from the docs
Ensure that the client has requested a valid set of scopes.
which has access to TokenRequest.getRequestParameters()
EDIT
See also the docs for the TokenEndpoint
Clients must be authenticated (...) to access this endpoint, and the client id is extracted from the authentication token. (...)

You must use HTTPS while generating Kong client credentials

Can anyone please help me out. I'm getting error while generating KONG client credentials on HTTP port 8000.
{
"error_description": "You must use HTTPS",
"error": "access_denied"
}
I have added trusted_ips = 0.0.0.0/0,::/0 in kong.conf also, but it didn't work.
You should do it over https(using port 8443 instead of 8000).If youre using localhost Do something like:
curl -X POST \
--url "https://127.0.0.1:8443/<route name>/oauth2/token " \
--header "Host: <route host>" \
--data "grant_type=password" \
--data "client_id=<clientid>" \
--data "client_secret=<clientsecret>" \
--data "provision_key=<provision_key>"\
--data "redirect_uri=http://localhost/cb/" \
--data "authenticated_userid=<userid>" \
--insecure
you can follow this link for further details on how to go about this

How to setup long code through programming way in Twilio?

In our application We have multiple firm setup and Within the firm, there are multiple users. So We want two way communication between firm number and user's number. In this, Whenever User registers a firm, we have to setup firm's phone number as long codes on Twilio account through programming way so that this firm can use this phone number for sending or receiving sms to/from firm's user. How can we do it in Twilio? Please provide specific link or advice.
Twilio Evangelist here.
Check out the Phone Numbers API docs.
The AvailablePhoneNumbers resource lets you search for phone numbers:
curl -G https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AvailablePhoneNumbers/US/Local.json \
-d "AreaCode=510" \
-u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'
the IncomingPhoneNumbers resource lets you purchase phone numbers:
curl -X POST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IncomingPhoneNumbers.json \
--data-urlencode "FriendlyName=My Company Line" \
--data-urlencode "PhoneNumber=+15105647903" \
--data-urlencode "VoiceMethod=GET" \
--data-urlencode "VoiceUrl=http://demo.twilio.com/docs/voice.xml" \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
and update purchased phone numbers:
curl -X POST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IncomingPhoneNumbers/PN2a0747eba6abf96b7e3c3ff0b4530f6e.json \
--data-urlencode "AccountSid=ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
--data-urlencode "SmsUrl=http://demo.twilio.com/docs/sms.xml" \
--data-urlencode "VoiceUrl=http://demo.twilio.com/docs/voice.xml" \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
Hope that helps.

Resources