Skip to main content
Nintex Community Menu Bar
Solved

Simple Nintex API REST call in PowerShell

  • May 26, 2026
  • 3 replies
  • 54 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???

Best answer by bsikes

Hi ​@paulsm4 ,

I suspect right now you have two problems:

  1. You do need to have the application/json as the content type (like you originally had)
  2. Your formBody isn’t formatted quite right when it gets passed through. I usually utilize ConvertTo-JSON to get the body into properly formatted JSON:
    1. $Headers = @{
      "Authorization" = "Bearer $token"
      "kryon-client-id" = "kryon-public-api"
      "kryon-auth-provider" = "aerobase"
      }

      $Body = @{
      "query" = @"
      {
      getRpaServerVersion
      }
      "@
      } | ConvertTo-Json -Depth 8

      Invoke-RestMethod -Uri $URI -Headers $Headers -Method POST -ContentType "application/json" -Body $Body

 

 

I at least know it’s working in 25.11. 

 

3 replies

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"

 


Forum|alt.badge.img+11
  • Contributor
  • Answer
  • May 29, 2026

Hi ​@paulsm4 ,

I suspect right now you have two problems:

  1. You do need to have the application/json as the content type (like you originally had)
  2. Your formBody isn’t formatted quite right when it gets passed through. I usually utilize ConvertTo-JSON to get the body into properly formatted JSON:
    1. $Headers = @{
      "Authorization" = "Bearer $token"
      "kryon-client-id" = "kryon-public-api"
      "kryon-auth-provider" = "aerobase"
      }

      $Body = @{
      "query" = @"
      {
      getRpaServerVersion
      }
      "@
      } | ConvertTo-Json -Depth 8

      Invoke-RestMethod -Uri $URI -Headers $Headers -Method POST -ContentType "application/json" -Body $Body

 

 

I at least know it’s working in 25.11. 

 


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

Thank you, bsikes!  That worked like a charm!