I've been trying to use the following query with the Microsoft graph API:
"groups?$filter=startswith(displayName, '" + term + "')"
So this term
's value is taken from an input html:
and through python I'm inserting it to perform the search with the query:
@APP.route('/search')
def search():
params = request.args.to_dict()
term = params.get('term')
queryGroup = "groups?$filter=startswith(displayName, '" + term + "')"
result = MSGRAPH.get(queryGroup, headers=request_headers()).data
return flask.render_template('home-page.html', result=result)
When I try looking for an existent group in the Azure AD, as a result I get this:
b'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">\r\n<HTML><HEAD><TITLE>Bad Request</TITLE>\r\n<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>\r\n<BODY><h2>Bad Request</h2>\r\n<hr><p>HTTP Error 400. The request is badly formed.</p>\r\n</BODY></HTML>\r\n'
According to Microsoft's Documentation, I see that my query is well structured.
I would like you guys to help me know, what may be failing here?
I'm using v1.0 of the API, and also tried it out with the same version in the graph explorer.(Where it worked out, which is odd for me)
I've been thinking about using the $search
parameter, but it does not work for this type of collection (Groups)
The full URI that I'm sending is :
https://graph.microsoft.com/v1.0/groups?$filter=startswith(displayName,<here I put the searched value>)
Thanks!
term = params.get('term')
the value ofterm
is null or empty. You could setterm
with hard code value and test it again. – Tom Sun - MSFT