Status 500 Error with private API token

  • 1
  • Question
  • Updated 4 months ago
I'm having trouble connecting to the new RightSignature API using my Private API Token. I'm getting a Status 500 error when I run this PowerShell code.

$text = "Private_API_TOKEN"
$bytes = [System.Text.Encoding]::Unicode.GetBytes($Text)
$token = [System.Convert]::ToBase64String($bytes);
$URL = "https://api.rightsignature.com/public/v1/me";
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add('authorization',"Basic " + $token);
$res = Invoke-WebRequest $URL -Method Get -Headers $headers

I'm sure I'm missing something simple.

Are there any code examples for the new API like there were for the old API (https://github.com/rightsignature/)?

Thanks!
Photo of Travis Cullitan

Travis Cullitan

  • 5 Posts
  • 0 Reply Likes

Posted 4 months ago

  • 1
Photo of Saravanan Kannan

Saravanan Kannan, Employee

  • 15 Posts
  • 3 Reply Likes
Travis,

This is our new api documentation page.

https://api.rightsignature.com/documentation/resources/

Thanks
Saravanan
(Edited)
Photo of Kelly Leeman

Kelly Leeman, Employee, Software Engineer

  • 53 Posts
  • 4 Reply Likes
Hi Travis,

The issue is that you are using unicode instead of UTF8 when encoding.  Please change "$bytes = [System.Text.Encoding]::Unicode.GetBytes($Text)"  to "$bytes = [System.Text.Encoding]::UTF8.GetBytes($Text)"
Photo of Travis Cullitan

Travis Cullitan

  • 5 Posts
  • 0 Reply Likes
Kelly - That solved my issue. Thanks!

It would be nice if there were some code samples since the new documentation seems a bit sparse. For example, I don't think the fact that  the token needs to be  BASE64 encoded and have "Basic " in front of it is in the API documentation. Is that just a web API standard?

Thanks again!
Photo of Kelly Leeman

Kelly Leeman, Employee, Software Engineer

  • 53 Posts
  • 4 Reply Likes
Hey Travis, 

Below is a link to an article i like about http authentication.  If you scroll to the Authentication schemes section you can see the different standards.  For example if you were using oath2 it would be bearer instead of Basic.  

https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication
Photo of Travis Cullitan

Travis Cullitan

  • 5 Posts
  • 0 Reply Likes
Thanks Kelly,  I really appreciate your help!