Forum Discussion

cdsdefender's avatar
cdsdefender
Copper Contributor
Aug 08, 2024

List software inventory API - Returns a 400 error if software_id contains a single quote.

I am using following API to get list of devices using software_id.

 

https://learn.microsoft.com/en-us/defender-endpoint/api/get-machines-by-software

GET https://api.securitycenter.microsoft.com/api/Software/microsoft-_-edge/machineReferences

 

I have a software_id that contains a single quote: google\chrome-_-queen's_closure

I have URL encoded it to pass into the API. After encoding, it becomes: google%5Cchrome-_-queen%27s_closure

 

Now my api call looks like this : 

https://api.security.microsoft.com/api/Software/google%5Cchrome-_-queen%27s_closure/machineReferences

 

In response i am getting following error.

 

{
"error": {
"code": "BadRequest",
"message": "The key value ('google\\chrome-_-queen's_closure') from request is not valid. The key value should be format of type 'Edm.String'.",
"target": "00-18cb5c3c4880e2df7e606358b4e825ab-ac6e7d51804be7dd-00"
}
}
 

I have checked that this is an issue with the single quote, and the API is not handling it correctly.

Can someone please help me resolve this issue? Is this a limitation of the API?

 

    • cdsdefender's avatar
      cdsdefender
      Copper Contributor
      Thanks for quick reply.
      I have tried to escape single quote by using double quotes before it but still it is not working.

      https://api.security.microsoft.com/api/Software/google%5Cchrome-_-queen%22%27s_closure/machineReferences

      Response :
      {
      "error": {
      "code": "BadRequest",
      "message": "The key value ('google\\chrome-_-queen\"'s_closure') from request is not valid. The key value should be format of type 'Edm.String'.",
      "target": "00-8605ae4708520f309608e2e73dd83887-d0613469dba4777d-00"
      }
      }


      Also tried to escape whole word and put double quotes before whole word but not working that also.

Resources