Skip to main content
Nintex Community Menu Bar
Question

Simple Nintex API REST call in PowerShell

  • May 26, 2026
  • 1 reply
  • 29 views

Forum|alt.badge.img+4

I’m trying to make a couple of simple “Hello world” queries with the Nintex RPA REST API.

The documentation examples use Postman, but that’s unavailable in my environment.  So I’m trying to use Powershell instead.

My second API call, a graphql query to get the RPA version, is failing with “InvalidOperation”.

Here’s the code:

# Get Access Token:
$response = "XXX"
$uri = "http://MY_NINTEX_HOSTNAME/auth/realms/Kryon/protocol/openid-connect/token"
$contentType = "application/x-www-form-urlencoded" # Implicitly set to "application/x-www-form-urlencoded" for POST method calls
$formBody= @{
client_id="kryon-public-api"
grant_type="password"
username="MY_NINTEX_USER"
password="NINTEX_USER_PASSWORD"
}
$response = Invoke-RestMethod -Uri $uri -Method POST -ContentType $contentType -Body $formBody
$access_token = $response.access_token
#Write-Host "Get Access Token response: " $response
#Write-Host "access_token: " $access_token

# Get RPA Version:
$response = "XXX"
$uri = "http://MY_NINTEX_HOSTNAME/nintex-public-api/graphql"
$contentType = "application/json"
$httpHeaders = @{
"Authorization" = "Bearer $access_token"
"Accept" = "application/json"
"kryon-client-id" = "kryon-public-api"
"kryon-auth-provider" = "aerobase"
}
$formBody= @'
query {
getRpaServerVersion
}
'@
$response = Invoke-RestMethod -Uri $uri -Method POST -Headers $httpHeaders -ContentType $contentType -Body $formBody
Write-Host "Get RPA Version response: " $response

  <= The first  API call, “Get access token” works OK;
        The next  call, “Get RPA version” (GraphQL) call fails with this error:

+ $response = Invoke-RestMethod -Uri $uri -Method POST -Headers $httpHe ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
Get RPA Version response: XXX

Q: What am I doing wrong???

1 reply

Forum|alt.badge.img+4
  • Author
  • Nintex Partner
  • May 27, 2026

I modified the Powershell “Invoke-Restmethod” slightly, REMOVING “Accept: application/json” from the headers, and “-ContentType application/json” from the command.

 

Now I’m getting a different Nintex error: “Forbidden":

Code:

# Get RPA Version:
$response = "XXX"
$uri = "http://VHAPREAPPRPABOT.va.gov/nintex-public-api/graphql"
$contentType = "application/json"
$httpHeaders = @{
"Authorization" = "Bearer $access_token"
"kryon-client-id" = "kryon-public-api"
"kryon-auth-provider" = "aerobase"
}
$formBody= @'
query {
getRpaServerVersion
}
'@
$httpHeaders | Out-String | Write-Host
$response = Invoke-RestMethod -Uri $uri -Method POST -Headers $httpHeaders -Body $formBody
Write-Host "Get RPA Version response: " $response


Result:

Name                 Value
---- -----
kryon-auth-provider aerobase
Authorization Bearer eyJhbGciOiJSUz...
kryon-client-id kryon-public-api

Invoke-RestMethod : {"responseMeta":{"trxId":"c8eddd69-e667-4ddb-8fa2-f667f60dfa4c","reqId":"c8eddd69-e667-4ddb-8fa2-f6
67f60dfa4c","message":"Forbidden"}}
At E:\Ricoh\psm\invoke-api1.ps1:78 char:13
+ $response = Invoke-RestMethod -Uri $uri -Method POST -Headers $httpHe ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc
eption
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
Get RPA Version response: XXX
<= Current Nintex error: "Forbidden"