FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
Dear Community User! We are updating our platform to a new
system.
Read more: Important
information on the platform change.
04-30-2024 04:25 PM
Hallo,
Ich versuche gerade den in diesem Post beschriebenen Prozess in powershell zu implementieren: https://developer.community.boschrexroth.com/t5/ctrlX-WORKS/ctrlX-PLC-Engineering-2-4-Login-and-Down...
Nach dem erfolgreichen CommunicatioSettingsJob versuche ich aus Powershell den DeviceUserLoginJob zu starten. Dieser schlägt fehl mit der Meldung "Device Login is not successful".
Weitere Fehlermeldungen sind in dem ErrorLog zu finden:
Overall: 00:00:00.0191109
**** Finished executing _ICustomizedCommand_ IStandardCommand with Guid={9d09e965-6254-46fd-9c21-b27fd2e97b52}: 'Rexroth.Studio.Common.Commands.plugin.OpenProjectCommand' - finished regularly after 3789 ms.
Rexroth.Studio.Common: [ERROR@Rexroth.Studio.Common.HttpService.DoTryPutPost(:0)] TryPut: HttpResponseCode for https://192.168.1.24/identity-manager/api/v1.0/auth/token is StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Alt-Svc: h3=":443"; ma=2592000
Information: The routes /identity-manager/api/v1 and /identity-manager/api/v1.0 are deprecated! Please the route /identity-manager/api/v2 instead! Be aware: the response schemas are changed!)
Pragma: no-cache
Cache-Control: no-store, no-cache
Date: Tue, 30 Apr 2024 14:05:58 GMT
Server: Caddy
Content-Length: 60
Content-Type: application/json; charset=UTF-8
}
Hier sieht es aus als würde im Hintergrund eine api/v1 gerufen.
Mein powershell call geht raus an
$Response = Invoke-RestMethod -Uri "http://localhost:9002/plc/engineering/api/v2/jobs" -Method Post -Body $postParams
Die Post Parameter, habe ich aus der API-Referenz Doku kopiert.
Wenn ich mir über die API-Referenz Doku die Jobs hole, dann sehen die beiden völlig identisch aus, nur dass der eine succeeded und der andere nicht:
{
"id": "28eb6bf1f5d4087",
"state": "Failed",
"progress": 100,
"jobType": "DeviceUserLoginJob",
"jobParameters": {
"nodeUrl": "/devices/Device",
"userName": "boschrexroth",
"password": "boschrexroth"
},
"jobResultInfo": "Device Login is not successful"
},
{
"id": "ead6f1710b8e218",
"state": "Done",
"progress": 100,
"jobType": "DeviceUserLoginJob",
"jobParameters": {
"nodeUrl": "/devices/Device",
"username": "boschrexroth",
"password": "boschrexroth"
},
"jobResultInfo": "DeviceUserLoginJob is successful."
}
Ich verwende ein VirtualControl der Version 2.4 und ein PLC Engineering der Version 2.4.
Was übersehe ich hier?
Vielen Dank für die Antwort und viele Grüße
Solved! Go to Solution.
04-30-2024 08:08 PM - edited 04-30-2024 08:09 PM
Working Powershell script together with associated output:
$ip_adr = "localhost:9002"
$result = Invoke-WebRequest `
-Uri http://$ip_adr/plc/engineering/api/v2/jobs `
-Method POST `
-Body '{"jobType":"DeviceUserLoginJob","jobParameters":{"nodeUrl":"/devices/Device","username":"boschrexroth","password":"boschrexroth"}}' `
| ConvertFrom-Json
$job_id = $result.id
Write-Output $result
Start-Sleep -Seconds 2
$result = Invoke-WebRequest `
-Uri http://$ip_adr/plc/engineering/api/v2/jobs/$job_id `
-Method GET `
| ConvertFrom-Json
Write-Output $result
pause
I think the issue is that you have used "userName" in your POST params. It should be "username".
05-07-2024 10:13 AM
Oookay! 😄
Classic case of blindness. I really did not see that. Double/Triple checked...
Thank you very much.