Make REST-Based Calls With An API Key

Make REST-Based Calls With An API Key

This article provides the resources to support the task of making REST-based calls with an API Key.

 

  1. Use The API Key
    1. Example HTTP Request
    2. Example PowerShell Request With Invoke-WebRequest
    3. Example PowerShell Request With Invoke-RestMethod
    4. Example cUrl Request Example PowerShell Request
    5. Example Response

Use The API Key

The following are examples of using the API key.

The caller passes the API key in the Authorization header like a bearer token.

Example HTTP Request

POST /application HTTP/1.1

Content-Type: application/json

Authorization: Bearer YourApiKeyHere

Host: api.YourSubDomain.fuuz.app

Content-Length: 111

 

{"query":"query {\n\tcurrentUser {\n\t\tuser {\n\t\t\temail\n\t\t}\n\t\ttenant {\n\t\t\tname\n\t\t}\n\t}\n}\n"}

Example PowerShell Request With Invoke-WebRequest

$headers=@{}

$headers.Add("Content-Type", "application/json")

$headers.Add("Authorization", "Bearer YourApiKeyHere")

$response = Invoke-WebRequest -Uri 'https://api.YourSubDomain.fuuz.app/application' -Method POST -Headers $headers -ContentType 'application/json' -Body '{"query":"query {\n\tcurrentUser {\n\t\tuser {\n\t\t\temail\n\t\t}\n\t\ttenant {\n\t\t\tname\n\t\t}\n\t}\n}\n"}'

Write $response

Example PowerShell Request With Invoke-RestMethod

$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"

$headers.Add("Authorization", "Bearer YourApiKeyHere")

$headers.Add("Content-Type", "application/json")

 

$body = @"

{`"query`":`"query {`\n`\tcurrentUser {`\n`\t`\tuser {`\n`\t`\t`\temail`\n`\t`\t}`\n`\t`\ttenant {`\n`\t`\t`\tname`\n`\t`\t}`\n`\t}`\n}`\n`"}

"@

 

$response = Invoke-RestMethod 'https://api.YourSubDomain.fuuz.app/application' -Method 'POST' -Headers $headers -Body $body

$response | ConvertTo-Json

Example cUrl Request Example PowerShell Request

 When using a Windows command terminal, it may be necessary to escape the double quotes and avoid single quotes, as is done in this example, which includes Windows-style command continuation with carets.

curl.exe https://api.YourSubDomain.fuuz.app/application ^

 -H "Authorization: Bearer YourApiKeyHere" ^

 -H "Content-Type: application/json" -d "{\"query\":\"query{  currentUser { user { email } }}\"}" -v

Example Response

{

     "data": {

          "currentUser": {

              "user": {

                   "email": "no-reply@domain.com

              },

              "tenant": {

                   "name": "Tenant Name

              }

          }

     }

}

    • Related Articles

    • User API Keys

      Open the Fuuz app. Select the Fuuz dropdown menu. Select the System option. Select the Access Control option. Select the User API Keys option. From here, it is possible to perform the following task or tasks. Search for a user API key. Create a user ...
    • Access Control Policy Groups

      Open the Fuuz app. Select the Fuuz dropdown menu. Select the System option. Select the Access Control option. The options include: Select the Access Control Policy Groups option. From here, it is possible to perform the following task or tasks. ...
    • Access Control Policies

      Open the Fuuz app. Select the MFGx dropdown menu. Select the System option. Select the Access Control option. Select the Access Control Policies option. From here, it is possible to perform the following task or tasks. Search for an access control ...
    • Configure Two-Factor Authentication

      This article provides the steps to configure two-factor authentication. Two-factor authentication (2FA) is a security measure that requires the user to input their password and then a generated 6-digit code. There are currently two different options ...
    • Basic API

      The Basic API Access identity provider type allows for basic authentication with conventional username and password. Basic API Access only allows access to the API and should only be used when the length of an API Key is too long for the provider to ...