API for deleting customer records

Updated by BCH Digital Support

This user guide will help you to delete customer records using an API.

Single or Batches

You will then need to decide if you want to delete in singles or batches.

Singles

If you are deleting singles, then the JSON should look like this –

{
"colA":"123456"
}

Batches

If you are deleting batches, then the JSON should look like this –

[{
"colA":"123456",
"colB":"123456",
"colC":"123456",
"colD":"123456",
"colE":"123456",
"colF":"123456",
"colG":"123456",
"colJ":"123456"
},
{
"colA":"123456",
"colB":"123456",
"colC":"123456",
"colD":"123456",
"colE":"123456",
"colF":"123456",
"colG":"123456",
"colJ":"123456"
}]

Generating the hash

Use the JSON string to generate the hash. Here is an example –

private static string GenerateHash(int clientId, int dbid, String password, String data)

{
var plainData = Encoding.UTF8.GetBytes(cid.ToString() + dbid.ToString() + password + PostData));
HashAlgorithm sha = new SHA512Managed();
var hashedData = sha.ComputeHash(plainData);
return HttpServerUtility.UrlTokenEncode(hashedData);
}

In c# you will need to remove the @ line feeds when generating the hash using the below. Converting to JSON and then back to string.

string PostData = JsonConvert.SerializeObject(JsonConvert.DeserializeObject(@"<body>;
For your account specific API password please contact support.

Building the URL

To build the URL you will need to know the following information –

  • Client ID
  • Database ID
  • The hash you have just generated

The URL should look like this -

https://api.pay-tel.co.uk/cppdb/api/database?cid=XXXX&dbid=XX&Hash=[The generated Hash from above]

6. POST

The body of the POST payload will be of type “Application/Json” and will contain the JSON generated in the steps above.

There is no http auth.

7. Error and response meanings

You may receive the following error and response codes –

 

Invalid clientid

Invalid database ID

Invalid hash

 

The response will contain counts of rows affected and any invalid entries.


How did we do?