通过Powershell的ISIM / ITIM REST连接

时间:2018-06-29 13:32:41

标签: rest powershell

我正在尝试创建与ISIM(6.0)的REST连接。根据:https://developer.ibm.com/answers/questions/289830/how-to-authenticate-to-isim-via-rest-apis/,共有3个步骤。 我设法创建了以下脚本

public class HomeActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
}

但是我无法仅获得任何连接:

[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12

$URL = "https://<hostname>:9443/itim/"
$LOGIN_URL = "$($URL)restlogin/login.jsp" 
$REST = "$($URL)rest/"
$LTPA = "$($URL)j_security_check"

$cookiejar = New-Object System.Net.CookieContainer 
$webrequest = [System.Net.HTTPWebRequest]::Create($LOGIN_URL); 
$webrequest.CookieContainer = $cookiejar 
$response = $webrequest.GetResponse() 
$cookies = $cookiejar.GetCookies($LOGIN_URL)

$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$session.Cookies.Add($cookies)
$body = ""

$Headers = "j_username=<username>&j_password=<password>"

$LTPA = "https://<hostname>:9443/itim/j_security_check?j_username=<username>&j_password=<password>"
$VAR = Invoke-RestMethod  -URI $LTPA -body $cookies -Method POST #-ContentType "application/json" #-body $cookies



Write-Host "3"
$ME = "https://<hostname>:9443/itim/rest/systemusers/me"
$VAR2 = Invoke-RestMethod  -URI $ME -body $cookies -Method POST

有人可以帮助我吗?

0 个答案:

没有答案