I am working on configuring Twilio messaging using the Twilio api with Subaccounts and MessagingServices.
I am able to create a MessagingService and an IncomingPhoneNumber using the Twilio api. However, if I attempt to set the SmsApplicationSid for the IncomingPhoneNumber to the sid of the MessagingService, I receive the following error:
{
"code": 400,
"message": "Application not found for sid: <--REDACTED-->",
"more_info": "https://www.twilio.com/docs/errors/400",
"status": 400
}
The more_info url (https://www.twilio.com/docs/errors/400) gives me a 404 not found which is not helpful.
I have tried setting the SmsApplicationSid both when first creating the IncomingPhoneNumber resource, as well as in an update after first creating the IncomingPhoneNumber without the SmsApplicationSid value. Both approaches respond with the same error.
The documentation isn't clear on this, but I decided to try adding the IncomingPhoneNumber to the MessagingService and that worked.
Url:
https://messaging.twilio.com/v1/Services/{smsApplicationSid}//PhoneNumbers
Method:
Post
Header:
"PhoneNumberSid", {incomingPhoneNumberSid}
Related
I have activated my app after getting approval of my Twitter developer account. I am trying to get twitter account associated with an email/phone number using Twitter Api.
It works perfect with params like screen_name,user_id but while trying email or phone number as a param the
Response says :
Could Not Authenticate you
Code is
import requests
url = "https://api.twitter.com/1.1/users/lookup.json?map=true&phone=1234567890"
payload = {}
headers = {
'Authorization': 'OAuth realm="http%3A%2F%2Fapi.twitter.com",oauth_consumer_key="<consumer_key>",oauth_token="<outh_token>",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1595318479",oauth_nonce="<nonce>",oauth_version="1.0",oauth_signature="<sig>"'
}
response = requests.request("GET", url, headers=headers, data = payload)
print(response.text.encode('utf8'))
Response :
{
"errors": [
{
"code": 32,
"message": "Could not authenticate you."
}
]
}
What are the reasons and suggestions on this ?
Will appreciate the positive feedback.
Have you tried using dynamic values generation for header like nonce generation, Timestamp, base_url according to query paramters?
It is not possible to use email or phone number as query parameters on the Twitter API. This is not supported as a feature in the API. See the documentation for supported parameters on users/lookup and users/search.
I'm making the following authenticated request:
GET
https://www.googleapis.com/youtube/v3/search?forMine=true&type=video&part=snippet&maxResults=50&api_key=<api_key>&order=date
I'm getting the following 400 response:
{
'error': {
'message': 'Invalid channel.',
'errors': [
{
'domain': 'youtube.search',
'message': 'Invalid channel.',
'location': 'channelId',
'locationType': 'parameter',
'reason': 'invalidChannelId'
}
],
'code': 400
}
}
As you can see, I don't specify a channelId in the request. This works for most of the accounts that I have authenticated with, but it is failing for 1 specific account and I'm not sure what I'm supposed to do with it.
Note that with the same authentication token and API key I am able to get the list of channels (https://www.googleapis.com/youtube/v3/channels) without error.
I'm guessing that the error at the least could be misleading? Or maybe there is a bug? Or maybe some sort of configuration issue?
In my case I have an account that is a member of an organization. You need to choose the organization, not the account itself (which didn't have a youtube channel created - hence the error).
Try going through the oauth flow in an anonymous window, it is not obvious what I mean if you are already logged in.
I tried to get a list of all conferences via Twilio PHP helper library, but get 404 error. My code:
$client = new Client($accountSid, $authToken);
foreach ($client->conferences->read() as $conference) {
var_dump($conference);
}
Error:
[HTTP 404] Unable to fetch page: The requested resource /2010-04-01/Accounts/twilio.account_sid/Conferences.json was not found
Thanks for the help in advance!
The problem was in bad credentials I setted. I used test credentials that are only for REST API testing purposes. When I setted correct credentials from https://www.twilio.com/console the problem was solved. Thanks Shachaf.Gortler for the some help.
I am trying to send over a Post request to sendgrid to generate an API key for a subuser.
This is what my code currently looks like
body = JSON.parse('{
"name":"My API Key",
"scopes": [
"mail.send",
"alerts.create",
"alerts.read"
]
}')
header = {'On-Behalf-Of' => 'my#email.com'}
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
response = sg.client.api_keys.post(request_body: body, request_header: header)
This code generates the API but on the main account instead of the Subuser account. The header is what drives where the API key is generated and I can seem to find any sources online that how the correct syntax for sending over the header to sendgrid.
If you could please help I would really appreciate it. Thanks!
I recently had to do this. You need to set the On-Behalf-Of headers when you instantiate the client not when you make the request:
```
#send_grid = API.new(api_key: #api_key, request_headers: {
'On-Behalf-Of' => #username
})
```
Then when you make a request with #send_grid it will send on behalf of the subuser -- and the API key will not show up in the list of api keys on the parent account
If I understand correct, you want to send email "From" another user. On Behalf of is non standard way of doing things.
For eg. https://sendgrid.com/docs/Classroom/Troubleshooting/Authentication/my_emails_are_displaying_as_on_behalf_of_or_via_in_some_mail_clients.html
You may want to try setting from instead of on-behalf-of
"from": {
"email": "from_address#example.com"
},
Refer to: https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/index.html
I am trying to create a managed device in Intune using the following Microsoft Graph but it keeps erroring out.
I also get an error when trying to update an existing device record.
I have the appropriate scopes and my account is an Intune admin. Any suggestions?
Here is the example error I receive when trying to update using PATCH
"error": {
"code": "InternalError",
"message": "An error has occurred - Operation ID (for customer support): 00000000-0000-0000-0000-000000000000 - Activity ID: 7d3aea54-282a-4911-99a5-af3d2422f81a - Url: https://fef.amsua0502.manage.microsoft.com/DeviceFE/StatelessDeviceFEService/managedDevices%28%278f312966-1c51-403b-9b3a-6cf52643fa70%27%29?api-version=5017-09-07 - CustomApiErrorPhrase: ",
"innerError": {
"request-id": "7d3aea54-282a-4911-99a5-af3d2422f81a",
"date": "2017-11-02T12:16:55"
}
}
They have changed the endpoint without updating the documentation..
Use: /deviceManagement/managedDevices
It's a beta so endpoints and (more frequently) required parameters in the json object chances..
I've figured out a lot of these changes by simply looking at posts from the developer mode in a browser.
The documentation is often behind the actual implementation.
And yea this worked. sorry for late response..
Edit2:
I don't have an example to create a managed device. But this is an example on how to create an empty device configuration:
$Endpoint = "https://graph.microsoft.com/beta"
## Win10
$Win10 = [pscustomobject]#{
'#odata.type' = "#microsoft.graph.windows10GeneralConfiguration"
'description' = "standard Windows 10 Device Restriction Configuration"
'displayName' = "Win10"
}
$Win10params = #{
ContentType = 'application/json'
Headers = $Header
Body = $Win10 | ConvertTo-Json -Compress
Method = 'POST'
URI = "$Endpoint/deviceManagement/deviceConfigurations"
}
Invoke-RestMethod #Win10params
But again. Take a look at the POST in the developer tab, and then start by trying out parameters from the top. If the documentation isn't updated with the least required parameters, you will have to go through it step by step..
They have changed the endpoint without updating the documentation..
Use: /deviceManagement/managedDevices