Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to search Dynamic fields via REST API #3750

Open
LordAro opened this issue Sep 2, 2024 · 0 comments
Open

No way to search Dynamic fields via REST API #3750

LordAro opened this issue Sep 2, 2024 · 0 comments

Comments

@LordAro
Copy link
Contributor

LordAro commented Sep 2, 2024

The REST API has no way of handling a "hash" structure of URL parameters

as far as I can tell, this is required for running TicketSearch on DynamicFields due to the operator structure it requires

# DynamicFields
# At least one operator must be specified. Operators will be connected with AND,
# values in an operator with OR.
# You can also pass more than one argument to an operator: ['value1', 'value2']
DynamicField_FieldNameX => {
Empty => 1, # will return dynamic fields without a value
# set to 0 to search fields with a value present.
Equals => 123,
Like => 'value*', # "equals" operator with wildcard support
GreaterThan => '2001-01-01 01:01:01',
GreaterThanEquals => '2001-01-01 01:01:01',
SmallerThan => '2002-02-02 02:02:02',
SmallerThanEquals => '2002-02-02 02:02:02',
},

(incidentally I think the comment here is "out of date" and uses the "old style" of keys?)

my %DynamicFieldsRaw;
if ( $Param{DynamicField} ) {
if ( IsHashRefWithData( $Param{DynamicField} ) ) {
$DynamicFieldsRaw{ $Param{DynamicField}->{Name} } = $Param{DynamicField};
}
elsif ( IsArrayRefWithData( $Param{DynamicField} ) ) {
%DynamicFieldsRaw = map { $_->{Name} => $_ } @{ $Param{DynamicField} };
}
else {
return %DynamicFieldSearchParameters;
}
}
else {
# Compatibility with older versions of the web service.
for my $ParameterName ( sort keys %Param ) {
if ( $ParameterName =~ m{\A DynamicField_ ( [a-zA-Z\d\-]+ ) \z}xms ) {
$DynamicFieldsRaw{$1} = $Param{$ParameterName};
}
}
}

if ( !defined $QueryParams{$Key} ) {
$QueryParams{$Key} = $Value || '';
}
# Elements specified multiple times will be added as array reference.
elsif ( ref $QueryParams{$Key} eq '' ) {
$QueryParams{$Key} = [ $QueryParams{$Key}, $Value ];
}
else {
push @{ $QueryParams{$Key} }, $Value;
}

As far as I'm aware, REST.pm would require some special handling of the parameters. There's no particular standard here, but Foo[Bar] is quite a common one and would work relatively well(?)

Just needs something that's able to convert DynamicField[Name]=flibble&DynamicField[Empty]=1&DynamicField[Like]=mysearchcontent into an actual DynamicField => {Name => "flibble", "Empty" => 1} hashref.

I imagine the SOAP layer would also need something, but I haven't looked very closely at that

I'm not entirely certain about this, so by all means correct me if I'm wrong (and turn this into a documentation improvement issue!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant