Start a new topic

API calls = "incorrect credentials"

I'm struggling to make simple curl requests to the API and I keep getting an "incorrect credentials!" response.  What am I doing wrong?

curl -d '{"auth":{"passwordCredentials":{"api-auth-accountid": "MY-API-AUTH-ACCOUNT-ID", "api-auth-applicationkey": "MY-APPLICATION-KEY"}}}' -H "Content-Type: application/json"

I tested this request with the api explorer and it gives the response I'd expect.

I'm finding the documentation really lacking and confusing - for example the api introduction page seems to list the incorrect (maybe version1?) url.

If anyone has some example API calls in Python they could share I'd be very grateful!

I've been trying as well. I'm using 

import requests

import json

import psycopg2

import sys

import pprint


#HTTP Header for Dear Systems

headers = {'Content-Type': 'application/json', 'api-auth-accountid': 'xxxxxx', 'yyyyyy', 'Accept': 'application/json'}


# Dear Systems API URL with Parameters

url = ''


# Request

response = requests.get(url, headers=headers)

status = response.status_code



# Get the response from the API endpoint.

message = response.content


But at the moment just getting incorrect credentials????

Here you go - This all functions.  Replace the 1234567890 and 0987654321 with your credentials.  


# -*- coding: iso-8859-15 -*-

import os, sys

import requests

import json

# define variables

apiauthaccountid = ‘1234567890’

apiauthapplicationkey = '0987654321'

headers = {'api-auth-accountid': apiauthaccountid, 'api-auth-applicationkey': apiauthapplicationkey, 'Accept':'application/json'}

saleNumber = input('Enter a sale number: ')

print('Thanks. Lets see what we\'ve got...')

#search for that sale number

url = '' + saleNumber

jsonDataAsPythonValue = json.loads(requests.get(url, headers=headers).text)

#make the (bad) assumption that the first result is our sale number.  

#Ideally you would check all returned sales to ensure their sale number is what was searched for

saleID = (jsonDataAsPythonValue['SaleList'][0]["ID"])

#use that sale ID to get our actual sale

url = '' + saleID

jsonSaleDataAsPythonValue = json.loads(requests.get(url, headers=headers).text)

Got it working

    headers = {'api-auth-accountid': apiauthaccountid,

           'api-auth-applicationkey': apiauthapplicationkey,

           'Accept': 'application/json'}


    url = ''

    response=requests.get(url, headers=headers)




Thanks for your help

Here's a simple example

from typing import List, MutableMapping, Optional
import requests
import datetime as dt
from unittest import TestCase

class Dear():
    def __init__(self, api_auth_accountid, api_auth_applicationkey):
        self.url = ''
        self.headers = {'api-auth-accountid': api_auth_accountid,
                        'api-auth-applicationkey': api_auth_applicationkey,
                        'Content-Type': 'application/json'}
        self.session = requests.Session()

    def get_all_products(self,modified_after:dt.datetime=None)-> Optional[List]:
        next_page = 1  # first page is 1
        page_limit = 500  # a constant
        data = []
        if not modified_after:
            modified_after =,1,1)

        modified_after_str = modified_after.strftime('%Y-%m-%d %H:%M:%S')
        while True:
            url = self.url + 'Products?page={page}&limit={limit}&modifiedSince={modifiedSince}'.format(page=next_page, limit=page_limit,
            resp = self.session.get(
                resp_json = resp.json()
                result = resp_json.get("Products",[])
            except Exception as e:
            if len(result) > 0:
                data += result
                next_page += 1
        return data


1 person likes this
Login or Signup to post a comment