Hi Arben,
You can try to pull the logs for fn_utilities to see how the URL is being formatted. I set loglevel=DEBUG under [resilient] to get more information about the API calls made.
------------------------------
Mark Scherfling
------------------------------
Original Message:
Sent: Mon October 24, 2022 06:02 AM
From: Arben Alia
Subject: Utility Functions for SOAR - Include data in Body
Hi Mark,
Event writing it down from the start it doesn't work. It returns error code 400 Bad Request
Thanks
------------------------------
Arben Alia
Original Message:
Sent: Tue October 11, 2022 04:36 PM
From: Mark Scherfling
Subject: Utility Functions for SOAR - Include data in Body
Rather than cut & paste my response, just type in the line yourself. I may have typed your line incorrectly as well, so please review for correctness.
Original Message:
Sent: 10/11/2022 4:18:00 PM
From: Arben Alia
Subject: RE: Utility Functions for SOAR - Include data in Body
How can I overcome this issue?
Thank you in advance Mark.
------------------------------
Arben Alia
Original Message:
Sent: Tue October 11, 2022 04:01 PM
From: Mark Scherfling
Subject: Utility Functions for SOAR - Include data in Body
Be careful of smart quotes. Some applications like to replace ascii quotes with curl quotes which are not recognized by python.
Original Message:
Sent: 10/11/2022 3:58:00 PM
From: Arben Alia
Subject: RE: Utility Functions for SOAR - Include data in Body
yes I'm using python 3. With the format method it returns
" was unable to complete because: KeyError: '"grant_type"' "
------------------------------
Arben Alia
Original Message:
Sent: Tue October 11, 2022 03:09 PM
From: Mark Scherfling
Subject: Utility Functions for SOAR - Include data in Body
Are you using the python 2 scripting engine? Try the python 3 engine or change to:
inputs.rest_body = '{"grant_type":"client_credentials", "client_id":"{}", "client_secret":"{}", "scope":"token"}'.format(ClientID, clientSecret)
Original Message:
Sent: 10/11/2022 1:55:00 PM
From: Arben Alia
Subject: RE: Utility Functions for SOAR - Include data in Body
Hi Mark,
Trying this way I get "was unable to complete because: ValueError: Invalid format specifier "
If I specify the clientID and clientSecret I get ": '400 Client Error: BAD REQUEST for url: https://id.sophos.com/api/v2/oauth2/token'"
Thanks
------------------------------
Arben Alia
Original Message:
Sent: Tue October 11, 2022 12:38 PM
From: Mark Scherfling
Subject: Utility Functions for SOAR - Include data in Body
Hi Arben,
Try formatting the rest_body as string-encoded json:
inputs.rest_body = f'{"grant_type":"client_credentials", "client_id":"{clientID}", "client_secret":"{clientSecret}", "scope":"token"}'
------------------------------
Mark Scherfling
Original Message:
Sent: Fri October 07, 2022 11:14 AM
From: Arben Alia
Subject: Utility Functions for SOAR - Include data in Body
Hi everybody,
I am trying to integrate Sophos host management on the SOAR.
I'm trying to use the Call RestAPI from Utility Functions for SOAR and I'm having a hard time including the data section in inputs.rest_body from the following request
curl -X POST -H 'Content-Type:application/x-www-form-urlencoded' -d 'grant_type=client_credentials&client_id=<id>&client_secret=<secret>&scope=token' https://id.sophos.com/api/v2/oauth2/token
I have tried a lot of combinations however I haven't figured it out yet. (the last attempt is the following one but still not working)
inputs.rest_body = f'grant_type=client_credentials&client_id={clientID}&client_secret={clientSecret}&scope=token'
Can somebody help me?
Thanks in advance
------------------------------
Arben Alia
------------------------------