Post

2 followers Follow
0
Avatar

REST api login problem

I've turned on the check box in Federated settings to allow api login, but I'm still getting "username and password do not match" when I try to login. I'm using powershell.

$auth = '{

"userName":"myUsername",

"password":"mypassword"

}'

$baseUri = 'https://api.clarizen.com/v2.0/services/authentication/getServerDefinition'

$r1 = Invoke-RestMethod -Uri $baseUri -Method Post -Body $auth

$baseUri = ($r1.serverLocation + "/authentication/login")

$r2 = Invoke-RestMethod -Uri $baseUri -Method Post -Body $auth -ContentType 'application/json'

 

Not sure how to get around this

Scott Spindler Answered

Please sign in to leave a comment.

2 comments

0
Avatar

Hello Scott,

I've tested the following and it worked: 

Could you please try the following code and let me know if it works? 

$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "text/plain")
$body = "{'UserName': 'someUsername', 'Password': 'somePassword'}"
$response | ConvertTo-Json
 
I hope this helps.
Roland
Roland Pumputis 0 votes
Comment actions Permalink
0
Avatar

Roland:

Thank you for your answer. I was informed that we should use an api key instead, so we set one up and it works.

Scott Spindler 0 votes
Comment actions Permalink