TheAlphaSchoolSystemPTYLTD / api-introduction

A basic introduction to the TASS API's.
16 stars 10 forks source link

401 Unauthorized #11

Closed richardthornton closed 4 years ago

richardthornton commented 4 years ago

I'm unable to create a successful GET request using credentials I have received for three separate schools. Both the python and php examples under api-introduction generate the same URL using the provided token, appcode, apiversion, method, endpoint and parameters, however the result is an IIS 401 - Unauthorized page with tailing JSON {"__status":"invalid","__msg":"Unauthorized","__invalid":{}}. Is this a common issue trying to get started? Any advice would be greatly appreciated.

richardthornton commented 4 years ago

I have spent quite a bit of time trying to resolve this myself to no avail, including now also testing the Powershell and JS examples. I'm happy to provide any further details. Please let me know.

jtc commented 4 years ago

Hi Richard

The company code would be a two-digit number between 01-99, I see you currently have V2.

Josh (not a TASS employee)

richardthornton commented 4 years ago

Thanks for the reply @jtc! That's what I was provided in the API Details from the three separate schools - all different, but all a letter and a number:

image

jtc commented 4 years ago

Ha, interesting! I'd never seen a company code like that but have just tested and it does indeed seem possible to create. I assume the schools are part of a larger system? Independent schools typically use just 01, which could be worth giving a go just in case, along with 02. Though I suspect you're right and that the school is indeed using the alpha-numeric code.

What parameters are you passing through?

Ask the schools to log in to TASS.web and go to System Admin > Utilities > API Gateway Maintenance > TASS APIs and click Log against the appropriate app code.

This should provide some more details and also allows them to "Print" an Excel file with the details to send to you.

richardthornton commented 4 years ago

I wrote a small script overnight to run the same GET request with all possible codes 00 through 99. Either I was throttled, or they all failed with a 401 error. So I have to presume the code is good. Either way, I've just pinged the team to check (yes, I'm working on a project for a network of schools).

I'm still just using the basic examples provided here in GitHub. So the parameters are just {"currentstatus":"current"}.

I've also requested that logging be enabled, so hopefully today I'll make some progress.

While I have you, is it usual for the 401 error to be a mixture of HTML and JSON?

image

jtc commented 4 years ago

That makes sense on parameters and company code. Hopefully the TASS log will have something more helpful.

Yep, HTML/JSON 401 is normal. TASS returns the JSON body with 401 status, and IIS sees the 401 and adds its HTML.

richardthornton commented 4 years ago

That's good to know and be prepared for early! :)

Really appreciate your help @jtc. I'll check back in here when I know more.

richardthornton commented 4 years ago

Ok! Progress, but I have no idea what it means:

An error occurred while trying to encrypt or decrypt your input string: '' Can not decode string "U

Any ideas?

jtc commented 4 years ago

Any ideas?

Unfortunately not. Logs seem to be a 50/50 split between giving the answer, or nonsense like that.

Might have to get the schools to loop you in with TASS support.

richardthornton commented 4 years ago

Might have to get the schools to loop you in with TASS support.

Doh. I tried that first and was sent here...

NOTE: TASS Support does not include assistance with API's where the vendor is not certified with us.

TASS has chosen GitHub as its platform to publish its API documentation. External development using TASS public APIs is very much a self-service approach.

If you have any questions about how to implement this I would recommend asking on our github page which is reviewed by our development manager regularly.

To get support I need to be certified by demonstrating a working integration, but to get a working integration I need support. I fear that's the end of the TASS journey for me!

jtc commented 4 years ago

Ah. Ricardo might be able to chime in here, otherwise, I'd be happy to jump on Zoom/Teams/etc with you and one of the school's IT with access to TASS.web API Gateway Maintenance. IIS server access would be preferable too, just in case.

I'll shoot you an email with my details.

richardthornton commented 4 years ago

I'm closing this one out. For the record, I was provided incorrect API credentials, but without any official support it took two weeks to get sorted.