How to send Trustpilot invitations through Trustpilot API? - api

In our app we are using this API call to retrieve our average rating score and display it on our website:
https://api.trustpilot.com/v1/business-units/{{BUSINESS_UNIT_ID}}/?apikey={{API_KEY}}
This works great.
Now if we want to send an invitation to rate our services to one of our customers, we use a very similar API call:
https://invitations-api.trustpilot.com/v1/private/business-units/{{BUSINESS_UNIT_ID}}/invitations?apikey={{API_KEY}}
Unfortunately, this doesn't work. We are getting this error:
{"fault":{"faultstring":"Invalid access token","detail":{"errorcode":"oauth.v2.InvalidAccessToken"}}}
What are we missing here?
We can't see why our API key works for the first call, but not for the second.
Thanks for any help.

In the first API call you are calling a public endpoint. For all public endpoints API key is enough because you are not accessing restricted data.
For your second API call (the invitations one), you are calling a private endpoint.
For all private APIs you need to authenticate yourself using the OAuth2 flow and include the access token in your request.
You can read more about the flow at:
https://developers.trustpilot.com/authentication

Related

Using WhatsApp API to find out if a number has an account

I'm trying to use the WhatsApp API, especially "POST /v1/contacts" at this url "https://developers.facebook.com/docs/whatsapp/api/contacts/".
But actually I don't know which url to use, I tried "https://api.whatsapp.com/v1/contacts" but I got a 404 Not Found Status.
I do my queries on postman.
Has anyone ever used it.
Thank you.
To achieve your goal, you'd need to try a different method because the API you're trying to call is not a public API, it's a private API.
Access private API is only available to verified Whatsapp for Business accounts.
It's Whatsapp For Business service provider you choose and successfully applied for.

Distributing API calls to users for web app

We are trying to call one of Google's APIs and analyze the data and then display it for the user on our site. We realize we can make calls to the API through our server using php or python, but because of Google's limit, we are looking for an option that will have the API call come from the user, instead of our server. Is there a way for a web app to distribute the requests amongst the users instead of make all the calls from our server?
Thank you very much as this has been a tricky one to Google.
I highly doubt that this is possible. The API request is per API key and you can't provide every user with their own API key.
If the scenario you are trying to achieve requests possibly the same data for multiple users. I highly suggest you save/cache the API request. This will minimize the times your server send API request to google since you saved that request to your server. You can then set an expiration for your saved/cached API request to renew X days.
Scenario
user 1: request data for item 123 from API.
server: sends request to API server, and save
user 2: request data for item 123
server: return saved API response

Inviting new user to private channel after inviting him by Slack API

I invited new user into slack team using slack API method users.admin.invite. I need to join him into some public and some private channels. Channels I gave as params in my inviting request, but with private channels I have trouble. It is not channels and it have another method to join user into it.
Method groups.invite need userId to join him.
Is it possible to add this user in the slack private channels (groups) using slack API?
The undocumented API method users.admin.invite has a channels property, where you can specify a list of IDs for the channels your want a new user to be automatically invited to.
This also works with private channels (I just tested it to confirm). All you need to do is to specify a private channel ID instead, which start with a G instead of a C.
You can use the API method groups.list to get the correct private channel ID. (private channels are called groups in the Slack API)
Example request:
https://slack.com/api/users.admin.invite?token=TOKEN&email=name#example.com&channels=G12345678
If you still getting errors using this approach than its most likely due to other issues, e.g. Slack does not recognize the email address or your access token does not have the admin right.
For more details please see the unofficial documentation of users.admin.invite on github, which I have updated accordingly.
Seems like this API endpoint isn't currently documented by Slack because it's still in development and could change in the future(which may be what you're running into now). Here's a link to a github issue talking more about it. https://github.com/slackhq/slack-api-docs/issues/30
I was able to find a github with documentation for the undocumented slack API endpoints, but those could have changed since they're not official https://github.com/ErikKalkoken/slackApiDoc/blob/master/users.admin.invite.md
From these unofficial API documentation it seems like you'll have to pass in the channelID instead of the channel name. To get channel IDs you'll just need to call the channels.list end point

REST APIs to fetch statistic api usage data from API Connect

This may look a dumb question to you. However, I am looking for a way to fetch API Connect internal data i.e. number of invocations of APIs exposed via API Connect , by which client etc. I know, there are individual dashboard/chart within API Connect. But, I want to build a explicit tool to monitor the same leveraging API Connect data.
is it at all possible ?
Thanks in advance
See the KC at https://www.ibm.com/support/knowledgecenter/SSMNED_5.0.0/com.ibm.apic.apionprem.doc/rapim_analytics_apieventrecordfields.html which will explain how to get the info you want.
Procedure
To obtain analytics data for a Catalog and API provider organization, issue the following call:
GET /v1/orgs/{orgId}/environments/{envId}/events
where
{orgId} is either the URL path segment or the ID of the API provider organization.
{envId} is either the URL path segment or the ID of the Catalog.
The following example shows a call that is issued from a browser and then shows all the event fields in the corresponding response. The call is issued to return two analytics events (limit=2), and includes a next parameter for requesting further events.
https://api-manager-server.company.com/v1/orgs/macs-shack/environments/sb/events?next&limit=2

Retrieve MemSiteAccId from Yodlee

The API Call - getSiteRefreshInfo in Yodlee API asks for the memSiteAccId.
I thought it is the same as itemAccountId that we got from Transactions. However, its not the same. Then, how do I retrieve memSiteAccId ?
Whenever you add an account using Site Based API(addSiteAccount1) you'll get- siteAccountId in the response. This is same as MemSiteAccountId, and you need to use the same to pass as an input in getSiteRefreshInfo.