Unable to make a Call in Python

I get “{u’errorCode’: u’E0000031’, u’errorSummary’: u’API validation failed: “filter”: must be a valid SCIM filter expression.’, u’errorId’: u’99b581b3-113e-46ea-8a12-9adba6a18288’}” as response while calling an API with filters in python.
{{url}}/api/v1/logs?filter=eventType eq “group.user_membership.add” & target.id eq “{{groupid}}”

Hi @Geet1

Can you please provide a snippet from your Python code that does this request to /logs endpoint?

Hi @dragos,

idDataUrl=“https://abc.okta.com/api/v1/groups/groupid/users
DepUrl=“https://abc.okta.com/api/v1/logs?filter=eventType eq ‘group.user_membership.add’ and target.id eq ‘groupid’”
headers = {‘Accept’: “application/json”,‘Content-Type’: “application/json”,‘Authorization’: "SSWS "}
print(“I am here”)
idData=requests.get(idDataUrl,headers=headers,verify=False) #works
content=idData.json()
depUserData=requests.get(DepUrl,headers=headers,verify=False) # doesn’t work
depData=depUserData.json()
print (“I am here”)
print (depData)

Can you please help me with this.

Hi @Geet1

The error occurs because the values in filter require double quotes instead of single quotes.

Please try the following script

import requests

DepUrl='https://org.okta.com/api/v1/logs?filter=eventType eq "group.user_membership.add" and target.id eq "00g56gu8vrEMAgGle2p7"'
headers = {"Accept": "application/json","Content-Type": "application/json","Authorization": "SSWS API_TOKEN_HERE"}
depUserData=requests.get(DepUrl,headers=headers,verify=False) # doesn’t work
depData=depUserData.json()
print (depData)

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.