cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

DeviceUserLoginJob schlägt aus powershell fehlt aber ist aus API-Referenz Doku erfolgreich

DeviceUserLoginJob schlägt aus powershell fehlt aber ist aus API-Referenz Doku erfolgreich

therusch
Established Member

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

 

 

2 REPLIES 2

bostroemc
Occasional Contributor

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

 

2024-04-30_13h01_05.png

I think the issue is that you have used "userName" in your POST params.  It should be "username".

2024-04-30_13h03_45.png

 

therusch
Established Member

Oookay! 😄 

Classic case of blindness. I really did not see that. Double/Triple checked...

Thank you very much. 

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist