Meteor HTTP post request not working with google add place api - http

I am using a HTTP post request to add places with google api in meteor js. The code I used is
var url = "https://maps.googleapis.com/maps/api/place/add/json?key="+googleKey;
Meteor.http.post(url,
{params: {
"location": {
"lat": -33.8669710,
"lng": 151.1958750
},
"accuracy": 50,
"name": "Google Shoes!",
"phone_number": "(02) 9374 4000",
"address": "48 Pirrama Road, Pyrmont, NSW 2009, Australia",
"types": ["shoe_store"],
"website": "http://www.google.com.au/",
"language": "en-AU"
}
},function(err, result){
console.log(arguments);
})
Am getting an error
{ [Error: failed [400] { "status" : "REQUEST_DENIED" } ]
I had tried with changing the params and googleKey,but there is no change in the error. Can somebody help me to use http post request with google api? Thanks in advance

Did you try data in place of params ?
Meteor.http.post(url,
{data: {
"location": {
"lat": -33.8669710,
"lng": 151.1958750
},
"accuracy": 50,
"name": "Google Shoes!",
"phone_number": "(02) 9374 4000",
"address": "48 Pirrama Road, Pyrmont, NSW 2009, Australia",
"types": ["shoe_store"],
"website": "http://www.google.com.au/",
"language": "en-AU"
}
},function(err, result){
console.log(arguments);
})
Works fine on my remote server, but in localhost I have an INVALID_REQUEST response, due to the key I think.

Based on the FAQs of the Places API documentation
The "status": "REQUEST_DENIED" is returned by the Google Places API Web Service when:
You have not activated the Google Places API Web Service in the Google Developers Console.
The key parameter is missing from your request.
The key parameter does not match the your API key in the Google Developers Console.
Your API key has not been correctly set up in the Google Developers Console:
If you are using a browser key, check that your allowed referer(s) are correct.
If you are using a server key, check that your allowed IP(s) are correct.
Android and iOS keys are not supported, please use a Browser or Server key.
The request was not sent as an HTTPS request, HTTPS is required for all Google Places API Web Service requests.
The incorrect HTTP method was used to send the request:
All requests must be sent as a GET request except for Place Add.
All Place Add requests must be sent as a POST request.
The request body you specified looks complete, you can check out the Google Developer Console if you missed some configuration on it.
Hope this helps!

Related

Can't create stack from template using Openstack Heat API

I'm trying to create a stack from a template using the Heat API. I'm using the API reference here as a guide. I have the following json in a file called single-server-template.json:
{
"stack_name": "api-test",
"template": {
"heat_template_version": "rocky",
"description": "Testing Heat API\n",
"resources": {
"server1": {
"type": "OS::Nova::Server",
"properties": {
"name": "Server1",
"image": "Ubuntu 22.04 (Jammy)",
"flavor": "alt.st1.small",
"key_name": "my_key",
"networks": "Internal"
}
}
}
}
}
I'm sending it with this: curl -X POST -H "X-Auth-Token:$OS_TOKEN" -d #single-server-template.json https://$OS_HOST_URL:8004/v1/$OS_PROJECT_ID/stacks
I've been at it for hours but no matter what I send I get a 400 error:
{"code": 400, "title": "Bad Request", "explanation": "The server could not comply with the request since it is either malformed or otherwise incorrect.", "error": {"type": "HTTPBadRequest", "traceback": null, "message": "The server could not comply with the request since it is either malformed or otherwise incorrect."}}
Things I've tried:
confirmed my environment vars are filled in correctly before sending
confirmed that the template itself is valid by spinning it up from the UI console
confirmed that other endpoints that require auth work as expected
screaming and/or crying
Can anyone confirm that what I've got is correct, or test it against your own openstack instance? The only other thing I can think of is that maybe my openstack provider has an issue with their API

Linked In API article thumbnails

I'm trying to migrate existing code that fetches organization posts from ugcPosts API to new versioned call of the Posts API(version 202210) and I'm facing issues with getting thumbnails for articles. Response that I get from Posts API doesn't contain thumbnail URL but instead it contains thumbnail URN(old ugcPost API returned thumbnail URL as a part of the post). Here is an example of an article post that I get from API
{
"isReshareDisabledByAuthor": false,
"createdAt": 1666603988797,
"lifecycleState": "PUBLISHED",
"lastModifiedAt": 1666603988797,
"visibility": "PUBLIC",
"publishedAt": 1666603988797,
"author": "urn:li:organization:1111",
"id": "urn:li:share:2222",
"distribution": {
"feedDistribution": "MAIN_FEED",
"thirdPartyDistributionChannels": []
},
"content": {
"article": {
"description": "some description",
"thumbnail": "urn:li:image:3333",
"source": "https://example.com",
"title": "some title"
}
},
"commentary": "some comment",
"lifecycleStateInfo": {
"isEditedByAuthor": false
}
}
I tried to use Images API to fetch thumbnail URL using a call
GET https://api.linkedin.com/rest/images/urn:li:image:3333
Unfortunately Linked In API responds with code 400 and message Invalid asset owner urn type provided: urn:li:article:4444
I don't get why it happens. Token that I'm using has enough permissions to fetch organization posts(token's scope contains permissions w_member_social, r_liteprofile, r_1st_connections_size, w_organization_social, r_member_social, r_organization_social, rw_organization_admin). Article id that presents in error message isn't anyhow connected to post id. It's also not clear why that asset is referenced as urn:li:article while the post itself is described as urn:li:share. To me it looks like Linked In API bug or am I doing something wrong?
Turns out there was a bug in Linked In API which was confirmed by their support. At this moment same calls work fine with version 202210

403 errors with keycloak API

I'm trying to use the Keycloak API (in node via keycloak-admin library) but I systematically get error 403.
I get successfully an access token via the library; by calling /auth/realms/master/protocol/openid-connect/token (on master realm) .
When I look inside my token, I seem to have the correct roles to be able to query the users :
{ "jti": "xx-..", "exp": 1585561478, "nbf": 0, "iat": 1585561418, "iss": "https://auth-mycompany.com/auth/realms/master", "aud": "mycompany-realm", "sub": "xx-..", "typ": "Bearer", "azp": "admin-cli", "auth_time": 0, "session_state": "xx-..", "acr": "1", "resource_access": { "mycompany-realm": { "roles": [ "view-users", "query-groups", "query-users" ] } }, "scope": "email profile", "email_verified": true, "name": "myname", "preferred_username": "myname", "given_name": "my name", "email": "myemail#mycompany.com" }
However , when I do a GET on https://auth-mycompany.com/auth/admin/realms/master/users or https://auth-mycompany.com/auth/admin/realms/mycompany/users ; I get 403 errors.
Maybe it's linked with the "aud" of my token ? Why do I get a token with "aud": "mycompany-realm" when I query master realm ?
Thanks for any help.
I eventually realize that this is due to the fact that I have implemented Port Restriction for admin endpoints. As described in the documentation, all endpoints starting with /auth/admin get a 403 response. Instead, these endpoints are accessible via another port (for example 9991) which is not accessible over the internet.
What I did to fix my issue : because both my Nodejs service and my keycloak server are running on the same kubernetes cluster, I change the authUrl of my keycloak server with its service name http://servicename.namespace.svc.cluster.local:9991/auth

How can I retrieve a RingCentral call recording from a monitored incoming call?

I'm monitoring incoming calls on RingCentral by listening for the Call Session Notifications (CSN) telephony/sessions event filter:
/restapi/v1.0/account/~/extension/~/telephony/sessions
From this, I will receive events like the following. The recordings property will appear to indicate a recording is available. How can I retrieve this recording?
{
"uuid":"12345678901234567890",
"event":"/restapi/v1.0/account/11111111/extension/22222222/telephony/sessions",
"timestamp":"2019-03-08T22:30:40.059Z",
"subscriptionId":"11112222-3333-4444-5555-666677778888",
"ownerId":"33333333",
"body":{
"sequence":7,
"sessionId":"1234567890",
"telephonySessionId":"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
"serverId":"10.11.12.13.TAM",
"eventTime":"2019-03-08T22:30:39.938Z",
"parties":[
{
"accountId":"11111111",
"extensionId":"22222222",
"id":"cs12345678901234567890-2",
"direction":"Inbound",
"to":{
"phoneNumber":"+16505550100",
"name":"Jane Doe",
"extensionId":"22222222"
},
"from":{
"phoneNumber":"+14155550100",
"name":"John Smith"
},
"recordings":[
{
"id":"44444444",
"active":false
}
],
"status":{
"code":"Answered",
"rcc":false
},
"missedCall":false,
"standAlone":false,
"muted":false
}
],
"origin":{
"type":"Call"
}
}
}
There are two ways to retrieve the recording using information in the Call Session Notification (CSN) event, specifically the recordings[0].id property and the sessionID property.
retrieving a full media URL by calling the call-log endpoint with the sessionId property
manually creating recording media URL using the recordings[0].id property.
Note 1: While the call is ongoing, the recording will not be available for retrieval, even when the recording id is present in the Call Session Notification event. The recording will be available to be retrieved shortly after the call concludes.
Note 2: Call recordings can be in MP3 or WAV format determined by the company. To distinguish check the response Content-Type header for the MIME type when retrieving the recording media file.
1) Retrieving Full Medial URL via Call Log API
Making an intermediate API call to the call-log API has the dual benefits of being the official approach for receiving a media URL an providing more metadata for the call. In this approach, the recording.id in the call-log record will match the recordings[0].id property in the Call Session Notification event.
Both the company account and user extension call-log APIs can be called with the sessionId parameter from the event as shown:
GET /restapi/v1.0/account/~/call-log?sessionId={sessionId}
GET /restapi/v1.0/account/~/extension/~/call-log?sessionId={sessionId}
In this example, the sessionId is 1234567890 so you would have a Company Call Log API URL as follows
GET /restapi/v1.0/account/~/call-log?sessionId=1234567890
The response object will have a recording property that provides hypermedia links to get the media file. The file can be WAV or MP3 format which is communicated in the response Content-Type header.
{
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/extension/22222222/call-log?view=Simple&sessionId=1234567890&page=1&perPage=100",
"records": [
{
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/extension/22222222/call-log/1234567890ABCDEFGabcdefgh?view=Simple",
"id": "1234567890ABCDEFGabcdefgh",
"sessionId": "1234567890",
"startTime": "2019-03-08T22:30:29.505Z",
"duration": 35,
"type": "Voice",
"direction": "Inbound",
"action": "Phone Call",
"result": "Accepted",
"to": {
"phoneNumber": "+16505550100",
"name": "Jane Doe"
},
"from": {
"phoneNumber": "+14155550100",
"name": "John Smith",
"location": "San Francisco, CA"
},
"recording": {
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/recording/44444444",
"id": "44444444",
"type": "OnDemand",
"contentUri": "https://media.ringcentral.com/restapi/v1.0/account/111111111/recording/44444444/content"
},
"extension": {
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/111111111/extension/22222222",
"id": 22222222
},
"reason": "Accepted",
"reasonDescription": "The call connected to and was accepted by this number."
}
],
"paging": {
"page": 1,
"perPage": 100,
"pageStart": 0,
"pageEnd": 0
},
"navigation": {
"firstPage": {
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/extension/22222222/call-log?view=Simple&sessionId=1234567890&page=1&perPage=100"
},
"lastPage": {
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/extension/22222222/call-log?view=Simple&sessionId=1234567890&page=1&perPage=100"
}
}
}
2) Manually Creating Media URL
You can call the Recording API endpoint and retrieve the media directly by manually constructing the recording URL as follows:
https://media.ringcentral.com/restapi/v1.0/account/{accountId}/recording/{recordingId}/content
In this example, the accountId is 11111111 and the recordingId is 44444444 for the following:
https://media.ringcentral.com/restapi/v1.0/account/11111111/recording/44444444/content
The accountId in the URL path can be set to the currently authorized user's account using ~. Alternately, it can be set explicitly by extracting the accountId from the event property or using the accountId property in the relevant party object. Using ~ is the recommended way to set accountId.
Note: This this approach can be quick, it may be error prone as RingCentral has changed the media hostname once in the past. While there are no anticipated, future changes, calling the call-log API and retrieving the full media URL from the response is the safer and recommended approach. See below for this approach. This is only included as some people will try this and potentially run into issues later.
3) Hybrid Approach
The first approach of calling the call-log end point is the recommended approach, however, it involves an extra API call and most of the time the second approach should work fine.
A hybrid approach is to construct the URL as in approach 2 and then fall back to approach 1 if approach 2 returns a 404 or other error.

Does the RingCentral Call Log API Return a "Missed" Value?

In the RingCentral Online Account Portal (https://service.ringcentral.com) and endpoint apps, the call log display shows whether a call was Inbound, Outbound or Missed.
In looking at the API Reference for the Call Log API, it seems that it only sends back Inbound or Outbound for "Direction". Does the developer Call Log API return a "Missed" value? Is there another way to get this information via the Call Log API?
Ref: https://developer.ringcentral.com/api-docs/latest/index.html#!#RefCallLog.html
This question appears to be in reference to the Online Account Portal UI's "Type" column as shown in this screenshot:
The web UI's "Type" column shows Inbound, Outbound or Missed. This can be generated by using the response properties for both direction and result.
direction API response property will be Inbound or Outbound
result API response property is an enumerated value that includes Missed and other values including Voicemail which is the example screenshot. A full list is available in the link below:
Ref: https://developer.ringcentral.com/api-docs/latest/index.html#!#ResultStatusValues
Here is an example response:
{
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/call-log?view=Simple&showBlocked=true&withRecording=false&dateFrom=2018-08-27T06:18:00.000Z&page=1&perPage=100",
"records": [
{
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/call-log/22222222?view=Simple",
"id": "22222222",
"sessionId": "33333333",
"startTime": "2018-08-27T17:38:12.634Z",
"duration": 27,
"type": "Voice",
"direction": "Inbound",
"action": "Phone Call",
"result": "Missed",
"to": {
"phoneNumber": "+16505550101"
},
"from": {
"phoneNumber": "+16505550102",
"name": "LOS ALTOS CA",
"location": "Los Altos, CA"
}
}
],
...
}
Please read this blog to find out more information you can find from the call log.

Resources