GRAPH API Cannot filter enum - enums

I am trying to filter SSPR results from AAD directoryAudits using:-
https://graph.microsoft.com/beta/auditLogs/directoryAudits?filter=category eq 'SSPR'
This works fine, however if I try to filter on say the result:
result eq success
"result": "success"
I get the error:-
"message": "The string 'Microsoft.AAD.Reporting.operationResult'success'' is not a valid enumeration type constant.",
So I have searched in the metadata and found some appropriate enums, and tried them, but nothing seems to work!
This seems such a simple thing, but I can't seem to work out a way past it.
I'm not sure if it is just this field, or enums in general.
Please help :)

According to the error message the string 'Microsoft.AAD.Reporting.operationResult'success'' is not a valid enumeration type constant, it means that $filter success is not supported.
Per List directoryAudits API, the following attributes are supported by $filter.
But based on my test and you mentioned that category also is supported.
If possible, you could filter the result on the client as workaround.

Related

Power Automate get data from Project Online and Filter

I am using "Send an HTTP Request to Sharepoint" action, and I want to filter the output to only include the project with ID = [user input filed in "Manually trigger a flow"]
My Uri seems to not be working and can't find errors; I have used this action before with no problems, can't figure what syntax (?) problem I may have?
Here is the Uri:
_api/ProjectData/Projects()?$Filter=ProjectUID eq '#{variables('proj id')}'&?Select=ProjectName,ProjectWorkspaceInternalUrl,ProjectUID,ProjectIdentifier
Can anyone spot the problem?!
Thanks so much in advance :)
For the URI try the following instead:
/_api/ProjectData/Projects()?$filter=ProjectId eq guid'xxxxx' &$Select=ProjectName,ProjectWorkspaceInternalUrl,ProjectId,ProjectIdentifier
where xxxx is your project id or in this case #{variables('proj id')}
It makes it easier to deal with the data as it doesn't return an array.

D365 Web API / OData - Error while filtering relationship by "CascadeConfiguration" enum value

I want to retrieve all one-to-many relationships of an entity where the Delete value of the CascadeConfiguration property is equal to Cascade.
According to the documentation, I'm using the following request (api version 9.0):
[organization url]/RelationshipDefinitions/Microsoft.Dynamics.CRM.OneToManyRelationshipMetadata/?$filter=ReferencedEntity eq 'contact' and CascadeConfiguration/Delete eq Microsoft.Dynamics.CRM.CascadeType'Cascade'
or the equivalent
[organization url]/EntityDefinitions(LogicalName='contact')/OneToManyRelationships/?$filter=CascadeConfiguration/Delete eq Microsoft.Dynamics.CRM.CascadeType'Cascade'
Both return the error message:
Condition specified on property CascadeConfiguration of type RelationshipMetadataBase is invalid.
The syntax is correct and there is no typo, because if I try changing other part of the url (eg. CascadeConfiguration/WrongValue or Microsoft.Dynamics.CRM.CascadeType'WrongType'), I'm getting another error message.
I'm pretty sure the problem occurs because the RelationshipMetadataBase doesn't have a CascadeConfiguration property. The cast to a one-to-many relationship, which does possess it, is supposed to make it work.
If I use the filter clause $filter=IsCustomizable/Value eq false, the correct response is returned, because IsCustomizable is a property of RelationshipMetadataBase. This seems to confirm the previous point.
I am missing something?

Calling the right URI with ODATA using ODataClient with Expand

I have two tables which are related to each other and I would like to perform some querying with filters on both tables (one for each)
I am using a controller in c# that looks like this :
var list =
await client.For("T_Project")
.Filter("IsQuote eq false")
.Expand("T_Ref_StatusProject")
.Filter("Final eq false")
.FindEntriesAsync();
Here is the URI that I get with this code :
http://localhost:12494/gp/T_Project?$filter=(IsQuote eq false) and (Final eq false)&$expand=T_Ref_StatusProject
However, I get an error saying bad request. I figure the one I want would look something like
http://localhost:12494/gp/T_Project?$filter=(IsQuote%20eq%20false)&$expand=T_Ref_StatusProject($filter=Final%20eq%20true)
The result is, however, exactly the same as if I didn't put any filter for the expand table.
So I have actually two question. How can I make it work in my c# code and what is the right URL syntax for it. I figure answering the first one will answer the second one.
My UI project (the one with the sample code) have Simple.OData.Client(5.0.0 alpha2) installed (which include Microsoft.Odata.Code (6.15.0)
My API have Microsoft.ASPNet.Odata V5.9.1 installed
Thanks
According to the ODATA documentation filtering on nested properties would look like this:
http://localhost:12494/gp/T_Project?$filter=(IsQuote eq false) and (T_Ref_StatusProject/any(d:d/Final eq false))
See QueryOptions 5.1.1.10.1 any, http://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/part2-url-conventions/odata-v4.0-errata03-os-part2-url-conventions-complete.html, see also "Addressing Derived Types" in the document which describes the concept in general.
I cannot help you on the first part of your question, as I am not using the C# client. But maybe you can check if the Filter() method accepts a lambda expression, where you can specify an expression that directly corresponds to the expanded entity.

GraphQL "not equal" operator?

I have a GraphQl API for listing a bunch of items, and I can query it perfectly etc.
But now I'd like to query for a subset of that list where one property can have 'all possible values except one specific one'.
For example, I want to query something like this:
{
items(status: !"Unwanted"){
id
}
}
That exclamation mark obviously doesn't work, but it illustrates what I am after.
Can't find any information about this online.
Does anybody know of a way to do this?
I would really hate having to enumerate all possible wanted values instead of just excluding the one unwanted value. This would be really bad design and is not scalable.
Thanks.
Use ne :
{
items(filter: {status: {ne: "Unwanted"}}){
id
}
}
If you can define the schema (implement the server) then you can add a second argument like statusExcept to the items field. Then in the resolve method check if status or statusExcept was set and deliver the items according to that.
It the server API is fixed there is afaik nothing that you can do except getting everything and filter on the client.
Using GraphQL version 4.3.2 the syntax has changed and you will need to use notIn
{
items(filter: {status: {notIn: "Unwanted"}}){
id
}
}

What does MailChimp error code -100 mean?

Had an application using the /lists/subscribe endpoint of the MailChimp API (v1.3 v2.0) that was returning a "-100" error code for a particular address for a time (but it's cleared now.)
This isn't in their list of exceptions – anyone seen this before and know if it might indicate anything useful? Or if it's in that range, but not on the list of "known exceptions", does that just mean an unknown server error?
I'm using this PHP library to talk to the API.
(Of course if I can get an answer MailChimp themselves I'll update this.)
lists/subscribe is actually a v2.0 call. The v1.3 equivalent is listSubscribe. -100 is, IIRC, a validation error and it should come with more description about what specifically the problem was with your submission.
A common validation issue with subscribe calls is passing the email address as a string instead of a JSON Object. This, for example, will return an error:
{
"email": "some.person#somedomain.com"
...
}
Instead, you'd want:
{
"email": { "email": "some.person#somedomain.com" }
...
}
It's a common problem because it's kind of silly to require that format, but that is what's required nonetheless. There are a billion other ways to get validation errors, of course, but that's a good one to double-check.

Resources