cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

unable to generate Access token using a refresh token for dumping a custom report

Hi Forum,

We are testing to pull a custom report get dumped in a specific path at regular intervals. Its working fine with the existing fnms api and when we try calling it from Flexera One API platform we are getting the below error. 

Following the thread in https://docs.flexera.com/flexera/EN/FlexeraAPI/GenerateAccessToken.htm#gettingstarted_2697534192_1116484 

Using the command to generate Access token getting the error as below.

 

PS E:\PRODDump> curl -s -i -X POST https://login.flexera.com/oidc/token -d "grant_type=refresh_token&refresh_token=vxyvalue"

Invoke-WebRequest : Missing an argument for parameter 'SessionVariable'. Specify a parameter of type 'System.String' and try again.

At line:1 char:6

+ curl -s -i -X POST https://login.flexera.com/oidc/token -d "grant_typ ...

+      ~~

    + CategoryInfo          : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException

    + FullyQualifiedErrorId : MissingArgument,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

Please suggest.

 

Regards,

 

 

(7) Replies

Hi ,

found where this is going wrong and instead of simply mention 'curl' i have used "curl.exe" and issue got resolved.

will try the next step for getting the custom report dump.

regards, 

ChrisG
By Community Manager Community Manager
Community Manager

The "cURL" tool referred to on the Generating an Access Token from Refresh Token page is the following tool: https://curl.se/

The output you've shown here suggests you are using the Windows PowerShell "curl" alias, which is an alias for the PowerShell Invoke-WebRequest cmdlet. That is quite different from the cURL tool: it serves a similar purpose (i.e. making HTTP requests), but takes a different set of parameters. If you want to use the PowerShell curl command (aka Invoke-WebRequest) instead of the cURL tool then you would need to work out a different set of parameters.

(Did my reply solve the question? Click "ACCEPT AS SOLUTION" to help others find answers faster. Liked something? Click "KUDO". Anything expressed here is my own view and not necessarily that of my employer, Flexera.)

Hi @ChrisG ,

thank you for the swift response. i've even tried Invoke-WebRequest and couldn't succeed as i'm not sure what parameters have to be set. But now i was able to generate the access token and see that the validity of the access token expires in 3600 seconds is this the default life time? Please help with the further guidelines using the access token as we are trying to get a custom report we have in our reports using the flexera one API.

Using the below code as suggested in https://docs.flexera.com/FlexeraOneAPI/ITAMDataAPI/#api-Files-filesShow  we are trying to get the custom report but unsuccessful.

curl -X GET\ -H "Authorization: Bearer [[abc123]]"\ -H "Accept: application/json,application/vnd.goa.error"\ "https://api.flexera.com/fnms/v1/orgs/{123}/files/{custom report name(with spaces)}"

but getting error:

 Could not resolve host: \

<html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
</body>
</html>

Please suggest.

 

Regards,

 

@winvarma - I expect the "Could not resolve host: \" error you are getting will be because of the stray "\" characters you have in your command.

In short, I don't think you should have these characters in there:

  1. The "\" characters shown in the example command line in the documentation you're referencing are there for line continuation in UNIX-like shells because the example command is spread over multiple lines.
  2. You used "\" in the middle of a single line.
  3. You are not entering the command over multiple lines, so don't need to use any kind of line continuation character.
  4. From your comments at the start of this thread, I think you are running in a Windows PowerShell or cmd shell anyway - neither of those shells use "\" for line continuation.

If you are entering this command on a single line, I expect you will want to use something like the following:

curl -X GET -H "Authorization: Bearer [[abc123]]" -H "Accept: application/json,application/vnd.goa.error" "https://api.flexera.com/fnms/v1/orgs/{123}/files/{custom report name(with spaces)}"

The quoting shown here should work in most common shells.

(Did my reply solve the question? Click "ACCEPT AS SOLUTION" to help others find answers faster. Liked something? Click "KUDO". Anything expressed here is my own view and not necessarily that of my employer, Flexera.)

@ChrisG  Can this API be used to retrieve any custom report, similar to the existing SOAP API? Based on the docs, and my own experience, the files endpoint only works to retrieve the files generated by the inventoriesIndex API. However, I see you're including a custom report name. I tried this (both with and without spaces) but I keep getting a "filename not found" error (my report is called "VM Report"). Here's my PowerShell:

Invoke-WebRequest -Headers $Header -Uri "https://api.flexera.com/fnms/v1/orgs/<myOrg>/files/VM%20Report"

@ticalotta - as far as I know there is not an API available on https://api.flexera.com/ to retrieve Flexera One ITAM custom report data. Take a look at the following site for information about Flexera One ITAM APIs that are currently available: IT Asset Management Data API.

There are various ideas logged in Flexera Ideas about APIs that could be added, but I don't think there is one there yet covering adding a supported API to retrieve custom report data. If that would be useful for you, do consider creating an Idea for people to vote on.

(Did my reply solve the question? Click "ACCEPT AS SOLUTION" to help others find answers faster. Liked something? Click "KUDO". Anything expressed here is my own view and not necessarily that of my employer, Flexera.)

Hi @ticalotta @ChrisG ,

As suggested , i Have created an Idea https://flexerasfdc.ideas.aha.io/ideas/FXONE-I-135 for getting custom reports from Flexera One using API where its not currently supported.

Please provide your vote.

 

Regards,