Closed johnakerlund closed 4 years ago
Did you encode each option between "add/item/" and "?apikey" with base64?
label="test"
password="password"
description="Description"
folderid="184"
login="username"
email="test@test.xyz"
url="url.com"
tags="test"
modify="1"
blabel=$(echo "$label" | base64 | tr '+/' '-_')
bpassword=$(echo "$password" | base64 | tr '+/' '-_')
bdescription=$(echo "$description" | base64 | tr '+/' '-_')
bfolderid=$(echo "$folderid" | base64 | tr '+/' '-_')
blogin=$(echo "$login" | base64 | tr '+/' '-_')
bemail=$(echo "$email" | base64 | tr '+/' '-_')
burl=$(echo "$url" | base64 | tr '+/' '-_')
btags=$(echo "$tags" | base64 | tr '+/' '-_')
bmodify=$(echo "$modify" | base64 | tr '+/' '-_')
domain.teampass.url/api/index.php/add/item/$blabel;$bpassword;$bdescription;$bfolderid;$blogin;$bemail;$burl;$btags;$bmodify?apikey=$apikey
i had it encoded to base64, however the error occured since it was not encoded with utf-8 (probably some default powershell setting..) When using this short script for testing the item gets added. Thank you!
function convertto-base64($input){
$encoding = [System.Text.Encoding]::GetEncoding(‘utf-8’)
[byte[]]$Bytes = $encoding.GetBytes($input)
$output =[Convert]::ToBase64String($Bytes)
($output).replace("+","-").replace("/","_")
}
$teampassurl = "teampass.url.se"
$apikey = "123456789"
$label = "Test user" |convertto-base64
$password = "password" |convertto-base64
$description = "description" |convertto-base64
$login = "username" |convertto-base64
$email = "mail@mail.com" |convertto-base64
$url = "www.domain.com" |convertto-base64
$tags ="tag" |convertto-base64
$folderID = "82" |convertto-base64
$anyone= "1" | convertto-base64
Invoke-RestMethod "$teampassurl/api/index.php/add/item/$label;$password;$description;$folderid;$login;$email;$url;$tags;$anyone""?apikey=$apikey"
This generates the string, which works
teampass.url.se/api/index.php/add/item/VGVzdCB1c2Vy;cGFzc3dvcmQ=;ZGVzY3JpcHRpb24=;ODI=;dXNlcm5hbWU=;bWFpbEBtYWlsLmNvbQ==;d3d3LmRvbWFpbi5jb20=;dGFn;MQ=="?apikey=123456789
Steps to reproduce
Invoke-RestMethod domain.teampass.url/api/index.php/read/folder/184?apikey=$apiKey
This command returns items in folder 184.Invoke-RestMethod domain.teampass.url/api/index.php/add/item/test;password;Description;184;username;test@test.xyz;url.com;test;1?apikey=$apikey
Expected behaviour
Adds new item with specified properties
Actual behaviour
err: Folder ID does not exist
Server configuration
Operating system: Debian 10
Web server: Apache/2.4.38
Database: 10.3.22-MariaDB
PHP version: PHP Version 7.3.14-1
Teampass version: TeamPass 2.1.27.36
API-version: 2.1.5 Updated from an older Teampass or fresh install: Fresh install
Teampass configuration file: