PS C:\Users\Python\UiPath> python .\UiPath_API_connect.py
Response is : {“error”:{“code”:“UnsupportedApiVersion”,“message”:“The HTTP resource that matches the request URI ‘UiPath Orchestrator’ does not support HTTP method ‘POST’.”,“innerError”:null}}
def __init__(
self,
client_id: str,
refresh_token: str,
base_url: str,
tokenurl="https://account.uipath.com/oauth/token",
):
"""
Initialize the API client.
Parameters:
client_id (str): The client ID for the API.
refresh_token (str): The refresh token for the API.
base_url (str): The base URL for the API.
token_url (str): The URL to get the token from. Defaults to "https://account.uipath.com/oauth/token".
"""
token_url = tokenurl
self.base_url = base_url
body = {
"grant_type": "refresh_token",
"client_id": client_id,
"refresh_token": refresh_token,
}
headers = {"Authorization": "Bearer", "Content-Type": CONTENT_TYPE_JSON}
response = requests.post(token_url, json=body, headers=headers)
access = response.json()
if response.status_code == 200:
self.access_token = access["access_token"]
else:
raise ValueError(
f"Failed to retrieve access token. Status code: {str(response.status_code)}. Response: {response.text}"
)
I have this method in an existing code try this you will have to edit out somethings like base url
Maybe you could try like this.
UiPath Cloud----Admin----External Applications----Add Application Under OAuth Apps, you can get APP ID and APP Secret, APP ID is POSTMAN’S Client ID, APP Secret is POSTMAN’S Client Secret, others argument just like you have filled.