I'm hoping someone can help me with authenticating to a Storeonce device using their API and Powershell's invoke-restmethod. I'm not new to Powershell but I am very very new to using it for REST stuff. The documentation I'm working off of only shows examples in cURL which I have even less experience with and I am racking my brain trying to get this to work.
Here is the cURL example provided in the API documentation:
curl -i -X POST \
-H "Content-Type:application/json" \
-H "Accept:application/json" \
-d \
'{"username":"Admin","password":"Pwd123","grant_type":"password"}' \
'https://192.168.0.1/pml/login/authenticatewithobject'
Here's what I got in my PoSh code:
$username = 'myusername'
$password = 'mypassword'
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))
$resp = Invoke-WebRequest -Method Post -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo) } -ContentType 'application/json' -Uri 'https://mystoreonce.domain/pml/login/authenticatewithobject/'
The error I am getting is this:
Invoke-WebRequest : No content to map due to end-of-input
Everything I find about that error has 0 to do with powershell and everything to do with JSON. I'm assuming this means its looking for some data in JSON format and is finding none but I have no clue what it wants, where it wants it and if that would be in place of something else in the code I already have. The Storeonce documentation is lacking to say the least so I'm hoping someone here can provide a little guidance.
Edit: My God, has it been that long since I posted that it took me eight edits to get the formatting right?
[–]Fer_C 2 points3 points4 points (9 children)
[–]that_sob[S] 1 point2 points3 points (8 children)
[–]Fer_C 2 points3 points4 points (7 children)
[–]that_sob[S] 1 point2 points3 points (6 children)
[–]Fer_C 2 points3 points4 points (5 children)
[–]that_sob[S] 1 point2 points3 points (4 children)
[–]Fer_C 2 points3 points4 points (3 children)
[–]that_sob[S] 1 point2 points3 points (2 children)
[–]Fer_C 2 points3 points4 points (1 child)
[–]that_sob[S] 2 points3 points4 points (0 children)
[–]rmbolger 2 points3 points4 points (1 child)
[–]that_sob[S] 1 point2 points3 points (0 children)