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

Getting BadRequest (Unauthorized) error from ESM rest api v2 during get query result

Hi,

I'm using ESM rest API v2 on ESM V11 and I sent a detailed query (qryExecuteDetail) and then I got a succeeded query details result.

I was waiting for the query to get completed (by using qryGetStatus).

When it finished, I started to fetch the query results data by separated pages of 100 items per page (by using qryGetResults).

The query returned with 2400 items thus I need to call the qryGetResults method 24 times to complete the receiving of all the data.

After the 14th page (and it's pretty consistent), I'm getting an unauthorized error from the ESM rest client. I assume it is related to the client's token validity but I don't sure what exactly to do.

Thanks.

1 Reply
Highlighted

Re: Getting BadRequest (Unauthorized) error from ESM rest api v2 during get query result

Hello,

This is actually very interesting...  Are you using python ?

Anyway,

I would suggest to add a exception handling part, re-login, re-do you query (qryExecuteDetail + wait qryGetStatus), and continue fetching the pages from the 14th until the next unauthorized error, and so on...

Here is a list of string matches that can be use to detect various authorization errors from ESM responses text :

"ERROR_InvalidSession",
"ERROR_INVALID_SESSION",
"Not Authorized User",
"Invalid Session",
"Username and password cannot be null",

 

Are you getting one of those ? 

 

If you are using python, I recommend you to check out msiempy, the ESM API python wrapper. It can significantly reduce your time spent coding script for the ESM API !

You Deserve an Award
Don't forget, when your helpful posts earn a kudos or get accepted as a solution you can unlock perks and badges. Those aren't the only badges, either. How many can you collect? Click here to learn more.

Community Help Hub

    New to the forums or need help finding your way around the forums? There's a whole hub of community resources to help you.

  • Find Forum FAQs
  • Learn How to Earn Badges
  • Ask for Help
Go to Community Help

Join the Community

    Thousands of customers use the McAfee Community for peer-to-peer and expert product support. Enjoy these benefits with a free membership:

  • Get helpful solutions from McAfee experts.
  • Stay connected to product conversations that matter to you.
  • Participate in product groups led by McAfee employees.
Join the Community
Join the Community