New REST API not returning anything

Can anyone help me setting up an API?

I have set the Resource URL to… (I have added correct code in place of my code here )
https://api.staffology.co.uk/employers/my code here/employees/

I then need an API Key… (lets assume the key is “xxxyyyzzz”)
So, I have set the HTTP Header to…

Label: Authorization
Key: Authorization
Value: Basic xxxyyyzzz

However, when I run the TEST all I get is “Status: Error”
Error: [object Response]

Resource settings for GET (one)


Resource URL: https://api.staffology.co.uk/employers/my code here/employees/
Relative path: /{id}

Can anyone tell me what I am doing wrong?

Thanks!

Could you check the full error message in the Web Inspector console? Ctrl+Shift+I (or Cmd+Opt+I on Mac) to open it.

I have looked at the Inspector Console and I see…
Failed to load resource: the server responded with a status of 401 (Unauthorized)

I will go and check the target, but I am not sure if I have setup the API Key correctly - please can you explain how this should be entered as a HTTP Header?

You can see from the web inspector request details if your Authorization header is being passed in the correct form to the API. The description of your setup looks correct to me.

SOLUTION

OK - to close this off… it turns out I was using the API directly in my header…
I have found out (clearly new to Headers…) that it needs to be encoded first - so I entered the API into this site to get the value… https://www.blitter.se/utils/basic-authentication-header-generator/
Thanks!

1 Like