pythonrequesttrustpilot

How get Business Unit ID from Trustpilot


I cannot get the Business Unit ID from API Trustpilot. I tried to use a different way with authorization, but still, get Unauthorized. Documentation from https://developers.trustpilot.com/business-units-api#find-a-business-unit doesn't help. I have also tried token, but still have the same issues - Unauthorized.

Can someone tell me what I do wrong?

My Python code:

import requests
apikey= xxxxx
URL = 'https://api.trustpilot.com/v1/business-units/find?name=b_name?apikey={0}'.format(apikey)
response = requests.request("get", URL)
response.reason

Solution

  • I found that it will work if the apikey is added to the headers.

    At the end, it looks like this:

    import requests
    apikey = "xxxxx"
    url = 'https://api.trustpilot.com/v1/business-units/find?name=b_name'
    payload = {'apikey': apikey}
    response = requests.request("get", url, headers= payload)
    response.reason
    

    See also the trustpilot api docs:
    https://documentation-apidocumentation.trustpilot.com/business-units-api-(public)#find-a-business-unit