Troubleshooting the API

Follow

First, see the steps in the API Overview article for setting up API access.

Testing with Postman

Postman is a popular tool for testing APIs. The Postman documentation will help you get started.

You will need your API Code (a ten-character code) and your access key (a much longer password). The API code goes to the URL (in yellow) and the access key is your password (in red):

Add a Content-Type header set to `application/json`. Also check the authorisation header is present:

If you get a 401 error, double-check your API code and access key, and that your IP address is in the range set for the the access key. If you still can't connect, contact Donorfy Support.

 

Testing with Python

Using the requests library, a connection can be set up like this:

import requests
import requests.auth

api_key = "12345ABCDE" # for example
access_key = "(from Settings  Configuration  API Settings)"
user_name = "API Testing"

session = requests.Session()
session.auth = requests.auth.HTTPBasicAuth(user_name, access_key)
session.headers.update({"Content-Type": "application/json"})

def url_for(endpoint):
    return f"https://data.donorfy.com/api/v1/{api_key}/{endpoint}"

response = session.get(url_for("constituents/123"))
# sends GET to https://data.donorfy.com/api/v1/12345ABCDE/constituents/123

For testing, it can be helpful to make a basic wrapper:

import requests
import requests.auth

class DonorfyApi:
    def __init__(self, tenant_code, user_name, access_key, subdomain="data"):
        self._url_base = f"https://{subdomain}.donorfy.com/api/v1/{tenant_code}"
        self._session = requests.Session()
        self._session.auth = requests.auth.HTTPBasicAuth(user_name, access_key)
        self._session.headers.update({"Content-Type": "application/json"})

    def request(self, method, path, *args, **kwargs):
        response = self._session.request(
            method, f"{self._url_base}/{path}", *args, **kwargs
        )
        if not response.ok:
            print(response.status_code, response.text)
        return response

    def get(self, path, *args, **kwargs):
        return self.request("GET", path, *args, **kwargs)

    def post(self, path, *args, **kwargs):
        return self.request("POST", path, *args, **kwargs)

    def put(self, path, *args, **kwargs):
        return self.request("PUT", path, *args, **kwargs)

    def delete(self, path, *args, **kwargs):
        return self.request("DELETE", path, *args, **kwargs)

Support

Donorfy Support allows you to report suspected issues with the API - i.e. genuine non-compliance, or reporting any outages, but please note that it does not cover troubleshooting your code.

If you need help with your code you will need the help of an approved Partner with API skills. Please refer to this page on our website - our Partners do charge for their time, and prices do vary from partner to partner.

 

Donorfy_Professional_Image_for_Support_Guides.jpg
The Donorfy API is a Professional-only feature. Essential subscribers, please contact us to find out more about upgrading.

Comments

0 comments
Please sign in to leave a comment.
Powered by Zendesk