TheAlphaSchoolSystemPTYLTD / employee-hr

EmployeeHR API
11 stars 6 forks source link

Unauthorised Error #33

Open HannaAzzi opened 3 weeks ago

HannaAzzi commented 3 weeks ago

Hi

I'm from Loreto Kirribilli. We are new to TASS and this is my first attempt with the TASS public API

I'm making the following PUT call curl --location 'https://loreto.nsw.tass.cloud/tassweb/api?method=getEmployeesDetails&appcode=LKHR&company=01&version=2&token=&date=01-01-1900'

I'm getting the following error 401 - Unauthorized: Access is denied due to invalid credentials.

The error I see in the TASS log An error occurred while trying to encrypt or decrypt your input string: Given final block not proper

I was told by TASS help to raise the issue here. Can you please help.

Regards

HannaAzzi commented 3 weeks ago

Please note, key changed after the above call

scottetass commented 3 weeks ago

Hi,

Welcome to TASS.

You are almost there, just change a couple of things:

  1. API parameters shouldn't be supplied individually as URL parameters, so remove &date='01/01/1900' from the URL
  2. The token in the URL is not your TASS Token key, it is a value generated by encrypting your request parameters, in JSON format, with your TASS token key.
  3. Don't use PUT, use either POST or GET.

Using your previous URL as an example, your JSON parameter string would be: { "date": "1900-01-01" }

You encrypt this value with your TASS token key, convert the result to a base64 string and ensure that it is URL encoded. You then use this value in your token URL parameter

curl --location 'https://loreto.nsw.tass.cloud/tassweb/api?method=getEmployeesDetails&appcode=LKHR&company=01&version=2&token=[generated token]

For more details, please refer to this page: https://github.com/TheAlphaSchoolSystemPTYLTD/api-introduction

Thanks, Scott