Advertisement
Guest User

Untitled

a guest
Apr 8th, 2020
1,164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.37 KB | None | 0 0
  1. import requests
  2.  
  3. USER_KEY = ""
  4. CLIENT_ID = ""
  5. ORCHESTRATOR_NAME = ""
  6. ACCOUNT_LOGICAL_NAME = ""
  7. TENANT_LOGICAL_NAME = ""
  8. API_URL = "https://platform.uipath.com"
  9.  
  10. # GET UIPATH SESSION
  11. orch_authentication_payload = {
  12.     "grant_type": "refresh_token",
  13.     "client_id": CLIENT_ID,
  14.     "refresh_token": USER_KEY
  15. }
  16.  
  17. s = requests.Session()
  18. r = s.post("https://account.uipath.com/oauth/token", data=orch_authentication_payload)
  19. access_token = r.json()["access_token"]
  20.  
  21. s.headers.update({'Authorization': f"Bearer {access_token}"})
  22. s.headers.update({'X-UIPATH-TenantName': f"{TENANT_LOGICAL_NAME}"})
  23.  
  24. ADD_ITEM_URL = f"{API_URL}/{ACCOUNT_LOGICAL_NAME}/{TENANT_LOGICAL_NAME}/odata/Queues/UiPathODataSvc.AddQueueItem"
  25. print(ADD_ITEM_URL)
  26. orch_queue_payload = {
  27.                       "itemData": {
  28.                                    "Priority": "High",
  29.                                    "Name": "PowerShell_Queue",
  30.                                    "DeferDate": "2020-04-08T06:52:37.648Z",
  31.                                    "DueDate": "2020-04-08T06:52:37.648Z",
  32.                                    "SpecificContent": {"Test@odata.type" : "#String",
  33.                                                        "Test" : "test"}
  34.                                   }
  35.                      }
  36.  
  37. response = s.post(ADD_ITEM_URL, data=orch_queue_payload)
  38.  
  39. print(response.text)
  40. print(response)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement